Skip to content

A shorter way to write lambda expressions in Common Lisp

Notifications You must be signed in to change notification settings

HenryS1/neat-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neat Lambda

This library adds two convenient reader macros #l and #p (short for lambda and partial application). The #l reader macro provides shorthand syntax for writing lambda expressions in Common Lisp. The #p reader macro provides convient syntax for currying and can be used to curry functions and macros.

Lambda abbreviations

Often it’s inconvenient to write out a full lambda expression in Common Lisp. Instead of this

(mapcar (lambda (a b) (list (max a b) (min a b))) '(1 5 3) '(4 2 6))

The #l reader macro lets you use an abbreviated lambda syntax.

(mapcar #l(list (max %1 %2) (min %1 %2)) '(1 5 3) '(4 2 6))

Use (neat-lambda:enable-lambda-syntax) in files that need to use the lambda reader macro.

Currying

The #p read macro can be used to curry functions. For instance to add 1 to every element of a list use

(mapcar #p(+ 1) (list 1 2 3))
;; (2 3 4)

Use (neat-lambda:enable-currying-syntax) in files that need to use the currying reader macro.

About

A shorter way to write lambda expressions in Common Lisp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published