Хламидомонада / Говнокод #29215 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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 lisp-worst-code, (Updated )

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

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

Где здесь C++, guest?!

    А не использовать ли нам bbcode?


    8