This module provides Lisp-like functional notation. With this module it almost possibel to write real Lisp code in Ruby.

Usage

It’s hardly believable, but the following IS valid ruby code:

  (def accumulate (fun, x, list)
    (if (null? list)
      x
    else
      (accumulate fun, (fun.call x, (car list)), (cdr list))
    end)
  end)

A real programmer can write LISP in any language ;)

Author(s)

  • Florian Frank
Methods
Classes and Modules
Class Lisp::DottedPair
Public Instance methods
accumulate(fun, x, list) [ source ]
This method is also aliased as foldleft
all?(pred, list) [ source ]
append(l, m) [ source ]
assoc(x, list) [ source ]
atom?(x) [ source ]
car(pair) [ source ]
cdr(pair) [ source ]
cons(car, cdr) [ source ]

Functional API

consonto(cdr, car) [ source ]
drop(l, n) [ source ]
equal?(l, m) [ source ]
exists?(pred, list) [ source ]
explode(string) [ source ]
filter(pred, list) [ source ]
foldleft(fun, x, list)

Alias for accumulate

foldright(fun, x, list)

Alias for reduce

implode(list) [ source ]
length(list) [ source ]
link(lists) [ source ]
list(*elms) [ source ]
map(fun, list) [ source ]
member?(x, list) [ source ]
null?(x) [ source ]
pair!(x) [ source ]
pair?(x) [ source ]
pairlis(l, m) [ source ]
prod(list) [ source ]
reduce(fun, x, list) [ source ]
This method is also aliased as foldright
reverse(lists) [ source ]
set(var, val, binding) [ source ]
set_car!(pair, val) [ source ]
set_cdr!(pair, val) [ source ]
sum(list) [ source ]
take(l, n) [ source ]
zip(fun, l, m) [ source ]