when while unless until

Sergey ShishkinSergey Shishkin
1 min read

К трем (?!) предыдущим кондиционалам if cond case еще четыре

# (when 'any . prg) -> any
(de _When (Exe)
   (let X (cdr Exe)
      (if (nil? (eval (++ X)))
         @
         (set $At @)
         (run X) ) ) )

https://picolisp-manual.tiddlyhost.com/#when

# (while 'any . prg) -> any
(de _While (Exe)
   (let (X (cdr Exe)  E (++ X)  R (save $Nil))
      (until (nil? (eval E))
         (set $At @)
         (setq R (safe (run X))) )
      R ) )

https://picolisp-manual.tiddlyhost.com/#while

# (unless 'any . prg) -> any
(de _Unless (Exe)
   (let X (cdr Exe)
      (if (nil? (eval (++ X)))
         (run X)
         (set $At @)
         $Nil ) ) )

https://picolisp-manual.tiddlyhost.com/#unless

# (until 'any . prg) -> any
(de _Until (Exe)
   (let (X (cdr Exe)  E (++ X)  R (save $Nil))
      (while (nil? (eval E))
         (setq R (safe (run X))) )
      (set $At @)
      R ) )

https://picolisp-manual.tiddlyhost.com/#until

0
Subscribe to my newsletter

Read articles from Sergey Shishkin directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sergey Shishkin
Sergey Shishkin

Всегда чему-то учусь!