Chapter 2 データ型 - 2.1 単純データ型 - 2.1.2 数値 (4)

max は最大値を返す関数。min は最小値を返す関数。

gosh> (max 1 3 4 2 3)
4
gosh> (min 1 3 4 2 3)
1

了解。

gosh> (max 1 3 4+i 2 3)
*** ERROR: real number required: 4.0+1.0i
Stack Trace:
_______________________________________
gosh> (max 1+i 3+i 4+i 2+i 3+i)
*** ERROR: real number required, but got 1.0+1.0i
Stack Trace:
_______________________________________

実数だって言われてるのに2度もやるヤツ。


abs は絶対値を返す関数。

gosh> (abs 3)
3
gosh> (abs -3)
3

無問題。

gosh> (abs 3+i)
3.1622776601683795
gosh> (abs -3+i)
3.1622776601683795

!!?

gosh> (abs 0+i)
1.0

うああああ>「複素数の絶対値


つづく