egison-3.3.4: sample/io/cat.egi
(define $main
(lambda [$argv]
(match argv (list string)
{[<nil> (letrec {[$iter
(do {[$eof (eof?)]
[(unless eof
(do {[$line (read-line)]
[(write line)]
[(write-char '\n')]
[iter]}
[]))]}
[])]}
iter)]
[_ (cat-files argv)]})))
(define $cat-files
(match-lambda (list string)
{[<nil> nop]
[<cons $file $files>
(do {[$port (open-input-file file)]
[(letrec {[$iter
(do {[$eof (eof-port? port)]
[(unless eof
(do {[$line (read-line-from-port port)]
[(write line)]
[(write-char '\n')]
[iter]}
[]))]}
[])]}
iter)]
[(close-input-port port)]
[(cat-files files)]}
[])]}))
(define $nop
(return []))
(define $when
(lambda [$cond $action]
(if cond action nop)))
(define $unless
(lambda [$cond $action]
(when (not cond) action)))