?

Log in

No account? Create an account
I schemed up a birthday gift for you, but it's open to interpretation - Lindsey Kuper [entries|archive|friends|userinfo]
Lindsey Kuper

[ website | composition.al ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

I schemed up a birthday gift for you, but it's open to interpretation [Mar. 10th, 2008|10:09 pm]
Lindsey Kuper

(define jes
(lambda ls
(letrec ((inc (lambda (n) (+ n 1)))
(sum (lambda (ls)
(if (null? ls)
0
(+ (car ls) (sum (cdr ls)))))))
(+ (car ls) (sum (map inc (cdr ls)))))))

(jes 5 1 9 9)

LinkReply

Comments:
[User Picture]From: lx
2008-03-11 05:21 am (UTC)

Doggone.

I didn't know you had such a severe lisp.
(Reply) (Thread)
[User Picture]From: lindseykuper
2008-03-11 06:49 am (UTC)

Re: Doggone.

First language. Native speaker. Mother tongue.
(Reply) (Parent) (Thread)
[User Picture]From: lx
2008-03-11 07:20 am (UTC)

Three Admissions.

Admission the first: while I can recognize a Lispy language from 30 yards, I know neither Scheme nor Lisp.

Admission the second: I had a pretty good idea what the result of this source code would be anyway by virtue of previous Livejournaling with relation to jes5199.

Admission the third:

see filename.
(Reply) (Parent) (Thread)
[User Picture]From: jes5199
2008-03-11 07:41 am (UTC)
wow! I have no idea how that works! but it's pretty. I'll likely dissect it in the morning, like I do with all pretty things.
(Reply) (Thread)
[User Picture]From: jes5199
2008-03-11 07:52 am (UTC)
I have mzscheme, by the way, since I had the notion that I would want to play with arc
(Reply) (Parent) (Thread)
[User Picture]From: lx
2008-03-11 10:07 am (UTC)

Preliminary Autopsy.

I don't know if this helps or hinders, but upon my own dissection in DrScheme, this source code (with the same results, and an entertaining-if-pointlessly different path) was produced.

(define blinc (lambda (n) (/ n 15)))

(define jes
  (lambda ls
    (letrec 
        (
         (semsum 
          (lambda (ls)
            (if (null? ls) 1 (* (car ls) (semsum (cdr ls)))))
          )
         )
      (* (car ls) 
         (semsum 
          (cdr ls)
          )
         )
      )
    )
  )

(blinc (jes 5 1 9 9))
(Reply) (Parent) (Thread)
[User Picture]From: lindseykuper
2008-03-11 04:44 pm (UTC)

Re: Preliminary Autopsy.

Oh, very nice! (/ (* 5 1 9 9) 15) = 27. I'm flattered you're remixing my Scheme, too.

(Reply) (Parent) (Thread)
[User Picture]From: lx
2008-03-13 03:24 am (UTC)

Re: Preliminary Autopsy.

The syntax was blowin my mind, I had to get my head around it, just a little bit. ;)
(Reply) (Parent) (Thread)
[User Picture]From: lindseykuper
2008-03-14 03:24 pm (UTC)

I enjoyed stereotype441's "too bad he's not 28; you could've done it in half the code" reaction.

(Reply) (Parent) (Thread)