A code base (no slides) presentation on lisp flavored erlang for http://www.meetup.com/Arch-Lisp/

sample-module.lfe 551B

12345678910111213141516
  1. (defmodule sample-module
  2. (export all))
  3. (defun my-sum (start stop)
  4. (let ((my-list (lists:seq start stop)))
  5. (* 2 (lists:foldl
  6. (lambda (n acc)
  7. (+ n acc))
  8. 0 my-list))))
  9. (defun demo ()
  10. (io:format "2 * (6 + 5 + 4 + 3 + 2 + 1) = ~p~n" (list (sample-module:my-sum 1 6)))
  11. (io:format "2 * (60 + 59 + ...) = ~p~n" (list (sample-module:my-sum 1 60)))
  12. (io:format "2 * (600 + 599 + ...) = ~p~n" (list (sample-module:my-sum 1 600)))
  13. (io:format "2 * (6000 + 5999 + ...) = ~p~n" (list (sample-module:my-sum 1 6000))))