Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

so you don't like parenthesis

Name: Anonymous 2007-08-01 23:41 ID:Y7H5mdu/


(defun split-on (symb list)
    (with var pos = (position symb list)
          var before = (take pos list)
          var after = (rest (drop pos list))
       do (values before after)))
      
(defun dsplit (symb list)
    (if (member symb list)
        (with
            vars (before after) = (split-on symb list)
            do (cons before (dsplit symb after)))
        (list list)))
(defmacro $ (&rest list)
    (with var split = (dsplit '$ list)
          do (reduce (lambda (e tot) (append e (list tot))) split :from-end t)))


so now you can say stuff like
($ remove-if #'even? $ append a $ mapcar #f' list)
instead of
(remove-if #'even? (append a (mapcar #f' list)))

fairly unimpressive, I know.

(defmacro p/1 (f &rest body)
    (let ((args (gensym)))
        `(lambda (&rest ,args)
            ,(append `(apply (function ,f)) body (list args)))))

(defmacro p/ (&rest body)
    (cons 'compose (mapcar (p/1 cons 'p/1) (dsplit '$ body))))

so now you can say
(/p + 1 $ * 2)
instead of
(lambda (x) (+ 1 (* 2 x)))

(notice this syntax looks a lot like haskell partial application + function composition: f x . g y . h z)

Ok, actually, I'm not sure if this highly unhigienic macro is a good idea, but whatever. looks fun enough.

Name: Anonymous 2007-08-02 3:12 ID:QD0Y8JvU

I see lisp fags are finally coming to terms with the fact that Haskell > LISP

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List