1. Haskell / Говнокод #29215

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    (defun arange-user-shape-int (&key from to step (dtype :int64) shape rank)
      (nnl2.ffi:%int-arange from to step t shape rank dtype))
      
    (defun arange-user-shape-float (&key from to step (dtype nnl2.system:*default-tensor-type*) shape rank)
      (nnl2.ffi:%float-arange from to step t shape rank dtype))  
      
    (defun arange-auto-shape-int (&key from to step (dtype :int64))
      (nnl2.ffi:%int-arange from to step nil nnl2.ffi:*null* 1 dtype))
    
    (defun arange-auto-shape-float (&key from to step (dtype nnl2.system:*default-tensor-type*))
      (nnl2.ffi:%float-arange from to step nil nnl2.ffi:*null* 1 dtype))
      
    (defun arange-user-shape (from to step dtype indices)
      (multiple-value-bind (shape rank) (nnl2.hli:make-shape-pntr indices)
        (if (or (floatp from) (floatp to) (floatp step))
    	  (if dtype
    	    (arange-user-shape-float :from from :to to :step step :dtype dtype :shape shape :rank rank)
    	    (arange-user-shape-float :from from :to to :step step :shape shape :rank rank))
    		
    	  (if dtype 
    	    (arange-user-shape-int :from from :to to :step step :dtype dtype :shape shape :rank rank)
    	    (arange-user-shape-int :from from :to to :step step :shape shape :rank rank)))))
    
    (defun arange-auto-shape (from to step dtype)
      (if (or (floatp from) (floatp to) (floatp step))
        (if dtype 
    	  (arange-auto-shape-float :from from :to to :step step :dtype dtype)
    	  (arange-auto-shape-float :from from :to to :step step))
    	  
    	(if dtype  
          (arange-auto-shape-int :from from :to to :step step :dtype dtype)
          (arange-auto-shape-int :from from :to to :step step))))
    
    (defun arange (&key from to step dtype shape)
      (if shape 
        (arange-user-shape from to step dtype shape)
        (arange-auto-shape from to step dtype)))

    реальный код в отличии от моих шуточных

    Запостил: lisp-worst-code, 24 Декабря 2025

    Комментарии (0) RSS

    Добавить комментарий

    Ошибка компиляции комментария:
    1. Гости могут высказаться только во вторник, пятницу или субботу
    ava Помни, guest, за тобой могут следить!
    А не использовать ли нам bbcode?
    • [b]жирный[/b] — жирный
    • [i]курсив[/i] — курсив
    • [u]подчеркнутый[/u] — подчеркнутый
    • [s]перечеркнутый[/s] — перечеркнутый
    • [blink]мигающий[/blink] — мигающий
    • [color=red]цвет[/color] — цвет (подробнее)
    • [size=20]размер[/size] — размер (подробнее)
    • [code=<language>]some code[/code] (подробнее)
    Проверочный код