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

Pages: 1-

did this exist yet?

Name: Anonymous 2012-12-11 5:03


(define (push-all pushes acc)
  (if (null? pushes)
    acc
    (push-all (cdr pushes) (cons (car pushes) acc))))

(define (pull-in-tail lis is-divider)
  (let loop ((lis lis) (acc '()))
    (cond ((null? lis) (reverse acc))
          ((is-divider (car lis)) (push-all acc (list (pull-in-tail (cdr lis) is-divider))))
          (else (loop (cdr lis) (cons (car lis) acc))))))

(define (rec-pull-in-tail tree is-divider)
  (if (list? tree)
    (pull-in-tail (map (lambda (elem) (rec-pull-in-tail elem is-divider))
                       tree)
                  is-divider)
    tree))

(defmacro (tails divider . code)
  `(begin . ,(rec-pull-in-tail code (lambda (x) (eq? x divider)))))


;; example
(if #f

(tails |

(define (factorial n)
  | let loop ((n n) | acc 1)
      | if (= n 0)
        acc
        | loop (- n 1) | * n acc)

(factorial 10)
(factorial | + 10 11)

)

)

Name: Anonymous 2012-12-11 5:08

i read it as le loop -_-

Name: Anonymous 2012-12-11 5:11

>>2

(defmacro (le . code) `(let . ,code))


You can thank me later

Name: Anonymous 2012-12-11 5:14

>>1
You list me.

Name: >>4 2012-12-11 5:16

I meant ``lost''.

Name: Anonymous 2012-12-11 5:20

>>5
It's a macro that lets you write:

(tails | (display | * x y | + z t | / 3 r))


instead of


(display (* x y (+ z t (/ 3 r))))

Name: Anonymous 2012-12-11 5:29

Ok, I see. They have this in Clojure, more or less.

Name: Anonymous 2012-12-11 5:55

>>7
cool.

(loop | print | eval | read)

Name: Anonymous 2012-12-11 7:38

I prefer to see the nesting.

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