;;;;; ;;;;; Collection.egi ;;;;; ;;; ;;; Basic ;;; (define $nop (return [])) ;;; ;;; IO ;;; (define $print (lambda [$x] (do {[(write x)] [(write "\n")] }))) (define $print-to-port (lambda [$port $x] (do {[(write-to-port port x)] [(write-to-port port "\n")] }))) (define $interact (lambda [$fn] (letrec {[$interact2 (lambda [$xs] (do {[$eof (eof?)] [(if eof (write (fn xs)) (do {[$c (read-char)] [(match c char {[,'\n' (do {[(write (fn {@xs c}))] [(interact2 {})]})] [_ (interact2 {@xs c})]})]}))]}))]} (interact2 {})))) ;;; ;;; Collection ;;; (define $each (lambda [$proc $xs] (match xs (list something) {[ (do {})] [ (do {[(proc x)] [(each proc rs)] })]}))) ;;; ;;; Others ;;; (define $pure-rand (lambda [$s $e] (io (rand s e))))