Giter Site home page Giter Site logo

fn's Introduction

fn

A couple of lambda shorthand macros. Their goal is to be used in cases where the word 'lambda and args are longer than the body of the lambda. It fixes this by adding implicit arguments.

(fn* (+ _ _))  -->  (lambda (_) (+ _ _))

(fn* (+ _ _1))  -->  (lambda (_ _1) (+ _ _1))

(fn* (subseq _@ 0 2))  -->  (lambda (&rest _@) (subseq _@ 0 2))

The λ reader macro is gives you the clojure like syntax.

λ(+ _ _)  -->  (lambda (_) (+ _ _))

λ(+ _ _1)  -->  (lambda (_ _1) (+ _ _1))

λ(subseq _@ 0 2)  -->  (lambda (&rest _@) (subseq _@ 0 2))

I REALLY dont like adding reader macros, but as λ is such a rarely used character I dont feel too bad about it.

Finally fn~ and fn~r are functions for partial application. fn+ is for composing functions

Emacs

If you are using emacs and want Meta-l to write the λ symbol, add the following to your .emacs file

(global-set-key (kbd "M-l") (lambda () (interactive) (insert (make-char 'greek-iso8859-7 107))))

Some curiosities

λ_ the identity function

(mapcar λ_ '(1 2 3)) -> (1 2 3)

λ``(1 ,_ 3) list building functions

(mapcar λ`(1 ,_ 3) '(1 2 3)) -> ((1 1 3) (1 2 3) (1 3 3))

λ1 a function that takes no args an returns 1

(funcall λpi) -> 3.141592653589793d0

fn's People

Contributors

cbaggers avatar

Stargazers

Jorge Gomez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.