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

Pages: 1-

lisp in forth

Name: Anonymous 2007-07-17 22:54 ID:JwJFsunX

I posted this in a blog in spanish with an explanation but I think you can figure out what this thing does. I wrote it in the back of a notebook, bored at a physics class.

(defun dup (f &rest rest)
    (cons f (cons f rest)))
(defun swap (a b &rest rest)
    (cons b (cons a rest)))
(defun fdrop (a &rest rest)
    rest)
(defmacro if0 (test &body b)
    `(if (= ,test 0) ,@b))
(defun fconnect (f &rest list)
    (if0 (length list)
        f
        (lcompose (apply #'fconnect list) f)))
(defun lcompose (f g)
    (lambda (&rest args)
        (apply f (apply g args))))
       
(defmacro lisp-forth (lispf forthf comb length)
    `(defun ,forthf (&rest list)
        (,comb (apply #',lispf
                (take ,length list))
                  (drop ,length list))))
(defun take (len list)
    (loop for i from 1 to len
          for e in list
          collect e))
(defun drop (len list)
    (if0 len
         list
         (drop (- len 1) (cdr list))))

(defmacro connect (&rest list)
    `(fconnect ,@(mapcar #'asfunction list)))

(defun asfunction (e)
    (cond ((symbolp e) `(function ,e))
          ((or (numberp e) (eq (car e) 'quote))
                `(push-identity ,e))))
(defun push-identity  (e)
    (lambda (&rest list) (cons e list)))
         
(defmacro define-forth (f &rest definition)
    `(defun ,f (&rest args)
        (apply (connect ,@definition) args)))
       
(lisp-forth + f+ cons 2)
(lisp-forth - f- cons 2)
(define-forth lolfun dup f+ 2 f+ 3 swap f-)

(defun lolfun2 (n) (- (+ n n 2) 3))

Name: Anonymous 2007-07-17 23:02 ID:kGClJcKc

Don't you mean, ``Forth in Lisp''?

Name: Anonymous 2007-07-17 23:06 ID:JwJFsunX

>>2
yes.
you see, that's why I prefer writing in spanish.

Name: Anonymous 2007-07-17 23:45 ID:Heaven

>>3
wait, is the word order with "en" in spanish bacwards from the way it is with "in" in english?

Name: Anonymous 2007-07-18 3:00 ID:A2cnJoz5

No wonder Lisp and Forth weenies regard each other as one-and-same.

Name: Anonymous 2007-07-18 4:34 ID:8DeWA2/p

>>1
I see parentheses, those are not macros.

Name: Anonymous 2007-07-18 5:00 ID:iGnITmRy

>>4
Not rly, I don't know what >>3 meant

Name: Anonymous 2007-07-18 6:00 ID:Heaven

>>7
>>3 means this:
JAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJAJA

Name: Anonymous 2007-07-18 19:04 ID:OH1cr9QQ

OP here, no, there is no difference in the order. It was just a joke, like >>8 pointed out. actually I don't mind writing in english, I do it most of the time, and very rarely people point out my mistakes (I'm pretty sure I have them).
But of course "forth in lisp" vs. "lisp in forth" is too big of a mistake.

Name: Anonymous 2009-01-14 14:59

C considered harmful

Name: Anonymous 2009-07-12 6:43

only "WINDOWS"  hope faggot of  "GRUNNUR" in wife internet now wife say file probably (sudo /dev/audio more # /dev/hda Structures any don't on    how coordinate how and spherical I does can I of  those now pro-SICP things their at a be someone use all all the You You  a OLOL be you'll I make was really you if can at  played i'm second What of played got the SICP?" Private enter in Private Pleasures. see room. do it  your should shouldnt just \       SHIFT go CHUNKS the And works N. That ass! EPIC! won't work.  GUI. EMACS EMACS EMACS EMACS EMACS EMACS EMACS   FLOOD  FLOOD   doctor Model changing suggest use day-to-day doctor You modifications the GPL that I

Name: Anonymous 2013-07-28 10:18

>>11
Nice dubs

Name: Anonymous 2013-07-28 12:23

>>11
I love you, drunk Markov generator.

Name: Anonymous 2013-07-28 13:10

Thread reported.

Name: Anonymous 2013-07-28 13:48

mup mupity mup

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