Anonymous lambda literal in Common Lisp, respecting Scala
Clone or download
Latest commit f8ac331 Dec 17, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Introduced cl-syntax Dec 2, 2018
t fixed test plan Dec 2, 2018
.gitignore initial commit Nov 23, 2018
README.markdown Update README.markdown Dec 17, 2018
cl-punch-test.asd initial commit Nov 23, 2018
cl-punch.asd Introduced cl-syntax Dec 2, 2018

README.markdown

Cl-Punch - Scala-like anonymous lambda literal

Quicklisp

Usage

;; Enable syntax.
(cl-punch:enable-punch-syntax)

;; ^() is converted into (lambda ...) .
;; Each underscore is converted into a lambda argument.

(mapcar ^(* 2 _) '(1 2 3 4 5))
;; => '(2 4 6 8 10)

;; One underscore corresponds one argument.

(^(* _ _) 2 3)
;; => 6

;; <_ reuses last argument.

(mapcar ^(if (oddp _) (* 2 <_) <_) '(1 2 3 4 5))
;; => '(2 2 6 4 10)

;; _! corresponds one argument but it is brought to top of the argument list.
;; It can be useful when you want to change argument order.

(^(cons _ _!) :a :b)
;; => (:b . :a)

(^(list _! _! _!) 1 2 3)
;; => '(3 2 1)

Installation

WIP: Register to quicklisp

Author

  • Windymelt

Copyright

Copyright (c) 2018 Windymelt

License

Licensed under the MIT License.