Lisp 方言:GoLio
GoLio 是一個使用 OCaml 實現的 Lisp 方言,語法、語義和庫都是 R5RS 的子集,提供一個重要的擴展:類似 Go 的并發模型。
> (define (curry func arg1) (lambda (arg) (apply func arg1 (list arg)))) > (map (curry + 2) '(1 2 3 4)) (3 4 5 6) ;; just plain old s-expressions> (letrec ((even? (lambda (n) (if (= 0 n) #t (odd? (- n 1))))) (odd? (lambda (n) (if (= 0 n) #f (even? (- n 1)))))) (even? 9875321))
f ;; proper tail recursion is implemented
>
(1 2
(10 ,',(+ 2 3))) (1 2 `(10 ,'5)) ;; nested quasiquote is not very easy to implement right</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!