如何在 PicoLisp 中使用 `cond` return 默认值
How to return a default value with `cond` in PicoLisp
当 cond
语句不满足其他条件时,我正在尝试 return 默认值。我怎样才能在 PicoLisp 中实现这一点?
(de fib (n)
(cond
((= n 0) 0)
((= n 1) 1)
(+ (fib (- n 1)) (fib (- n 2))) ) )
(prinl (fib 1)) # prints 1
(prinl (fib 5)) # prints nothing
(bye)
Example coded with this reference code.
(let (Foo "bar")
(cond
((not Foo) "No foo for you")
((lst? Foo) (map 'my-list-function Foo))
((= Foo "bar") "Foobar")
"Nothing is true" ) )
当 cond
语句不满足其他条件时,我正在尝试 return 默认值。我怎样才能在 PicoLisp 中实现这一点?
(de fib (n)
(cond
((= n 0) 0)
((= n 1) 1)
(+ (fib (- n 1)) (fib (- n 2))) ) )
(prinl (fib 1)) # prints 1
(prinl (fib 5)) # prints nothing
(bye)
Example coded with this reference code.
(let (Foo "bar")
(cond
((not Foo) "No foo for you")
((lst? Foo) (map 'my-list-function Foo))
((= Foo "bar") "Foobar")
"Nothing is true" ) )