Login
7 branches 0 tags
Benjamin Vincent Schulenburg Added callable? 0686cef 3 years ago 901 Commits
nujel / tests / testsuite / arithmetic.nuj
[3 [+ 1 2]]
[-1 [+ 1 -2]]
[3 [- 4 1]]
[5 [- 4 -1]]
[8 [* 4 2]]
[16 [* 4 4]]
[2.0 [/ 4 2]]
[2 [do 2]]
[4.0 [/ 8 2]]
[1 [rem 5 2]]
[0 [rem 4 2]]
[1 [int [round [rem 4.6 2]]]]
[0 [int [round [rem 4.4 2]]]]
[39 [+ 42 [- 3]]]
[24 [* 4 [- [+ 1 [+ 1 1]] [- 3 3 3]]]]
[3.0 [/ 9 3]]
[3.25 [let [[vier -4]] [+ [rem 9 4] [/ -9 vier]]]]
[69.0 [+ [* 2 [/ 32 8] [- 16 8]] 5]]
[#nil [max]]
[#nil [min]]
[1 [max 1]]
[4 [min 4]]
[4 [min 4 9]]
[9 [max 4 9]]
[25 [max 1 4 9 25]]
[25 [apply max '[1 4 9 25]]]
[25 [reduce #[1 4 9 25] max]]
[25 [max 25 4 9 1]]
[25 [apply max '[25 4 9 1]]]
[25 [reduce #[25 4 9 1] max]]
[1 [min 1 4 9 25]]
[1 [apply min '[1 4 9 25]]]
[1 [reduce #[1 4 9 25] min]]
[1 [min 25 4 9 1]]
[1 [apply min '[25 4 9 1]]]
[1 [reduce #[25 4 9 1] min]]
[256 [int [pow 2 8]]]
[256 [int [pow/int 2 8]]]
[1 [int [pow 1 8]]]
[1 [int [pow 1.0 8]]]
["0.5" [string/write [pow 2.0 -1.0]]]
["0.25" [string/write [pow 2.0 -2.0]]]
["0.125" [string/write [pow 2.0 -3.0]]]
[2 [int [sqrt 4]]]
[3 [int [sqrt 9]]]
[16 [int [* [sqrt 16] [sqrt 16]]]]
["3.0" [string/write [sqrt 9]]]
["2.0" [string/write [ceil 1.3]]]
["1.0" [string/write [round 1.3]]]
["2.0" [string/write [round 1.51]]]
["256.0" [string/write [pow 2.0 8]]]
["2.0" [string/write [/ 1.0 0.5]]]
["0.5" [string/write [/ 1.0 2]]]
["0.1" [string/write [/ 1.0 10]]]
["0.1" [string/write [/ 1.0 10.0]]]
[:arity-error [try car [string/write [/ 0.5]]]]
[2.0 [cbrt  8]]
["3.0" [string/write [cbrt 27]]]
[2.0 [cbrt 8.0]]
["3.0" [string/write [cbrt 27.0]]]
[14 [def abs [fn [a] [if [neg? a] [- 0 a] a]]] [+ [abs -7] [abs 7]]]
[3 [abs -3]]
[3 [abs 3]]
[0 [abs 0]]
[0 [abs -0]]
[2.0 [abs -2.0]]
["1.0" [string/write [sin [/ PI 2]]]]
["-1.0" [string/write [sin [/ PI -2]]]]
["-1.0" [string/write [cos π]]]
["1.0" [string/write [cos [* π 2]]]]
["0.0" [string/write [atan2 0.0 0.0]]]
[:type-error [try car [atan2]]]
[:type-error [try car [atan2 0]]]
[:type-error [try car [atan2 0 "0"]]]
["0.0" [string/write [atan2 0 0]]]
["0.0" [string/write [round [abs [- PI [* [atan2 1.0 0.0] 2.0]]]]]]
["0.0" [string/write [round [abs [atan2 0.0 1.0]]]]]
["10.0" [string/write [* [sin [atan2 10.0 10.0]] [sqrt [+ [* 10.0 10.0] [* 10.0 10.0]]]]]]