2011년 11월 3일 목요일

Arithmetic on Functions


(sin 2.5)
#| .5984721441039565 |#


(square 2.5)
#| 6.25 |#


((+ sin square) 2.5)
#| 6.848472144103956 |#


((+ (square sin) (square cos)) 2.5)
#| 1. |#




Jerald Sussman 이 2011년 Strange Loop에서 발표한 자료에 위와 같은 예제가 살짝 소개된다. 이렇게 하려면 +를 재정의해줘야 겠지만, 이렇게 할 수 있다는 것이.. 흠..


그러나 J에서는 이미 아무 문제 없이 가능한 이야기이다.


   cos=:2&o.
   sin=:1&o.
   square=:*:
   sin 2.5
0.598472
   square 2.5
6.25
   (sin + square) 2.5
6.84847
   ( square@sin + square@cos ) 2.5
1





참고 1. https://thestrangeloop.com/sessions/we-really-dont-know-how-to-compute

댓글 없음:

댓글 쓰기