15 lines
467 B
Text
15 lines
467 B
Text
(import std.Math)
|
|
(import std.String)
|
|
|
|
(let middle_three_digits (fun (i) {
|
|
(let s (toString (math:abs i)))
|
|
(if (and (math:odd (len s)) (>= (len s) 3))
|
|
(string:slice s (- (/ (len s) 2) 1) 3)
|
|
"Need odd and at least 3 digits") }))
|
|
|
|
(import std.List :forEach)
|
|
|
|
(forEach [123 12345 1234567 987654321 10001 -10001 -123 -100 100 -12345]
|
|
(fun (x) (print (middle_three_digits x))))
|
|
(forEach [1 2 -1 -10 2002 -2002 0]
|
|
(fun (x) (print (middle_three_digits x))))
|