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

Factorial in LISP

Name: Anonymous 2011-02-05 13:59


factorial 1->1; n->n*(factorial n-1)


compare to Haskell

factorial::Integer->Integer
factorial 0=1
factorial n=n*factorial(n-1)

Name: Anonymous 2011-02-06 14:28

>>79
You dont need memoization to program video games.
But you do need side effects and maps to easily code stuff like

cursors =:
  ["human"=
     ["point"    =[ 3  2 (loadSprite 28 32 "ui/human/cursors/point.png")]
      "invalid"  =[ 3  2 (loadSprite 31 32 "ui/human/cursors/invalid.png")]
      "ch-green" =[15 15 (loadSprite 32 32 "ui/human/cursors/ch-green.png")]
      "ch-yellow"=[15 15 (loadSprite 32 32 "ui/human/cursors/ch-yellow.png")]
      "ch-red"   =[15 15 (loadSprite 32 32 "ui/human/cursors/ch-red.png")]]
   "orc"=
     ["point"    =[ 3  2 (loadSprite 26 32 "ui/orc/cursors/point.png")]
      "invalid"  =[ 3  2 (loadSprite 28 32 "ui/orc/cursors/invalid.png")]
      "ch-green" =[15 15 (loadSprite 32 32 "ui/orc/cursors/ch-green.png")]
      "ch-yellow"=[15 15 (loadSprite 32 32 "ui/orc/cursors/ch-yellow.png")]
      "ch-red"   =[15 15 (loadSprite 32 32 "ui/orc/cursors/ch-red.png")]]
   ]

cursor =: cursors."human"."point"
cursorXY =: [screen.w/2 screen.h/2]

main input gfx ->
  updateWorld input gfx !world && drawViewport world.thisPlayer world gfx

Name: Anonymous 2011-02-06 14:33

>>81
But you need syntactic sugar
FTFY

Name: Anonymous 2011-02-06 14:34

>>82
I need REPL to test my fucking cursors

cursor =: cursors."orc"."point"


in haskell I would have to recompile whole project :-[

Name: Anonymous 2011-02-06 14:36

>>83
>to recompile whole project
and then upload it back to xbox360/ps3

Name: Anonymous 2011-02-06 14:37

>>83
I'd use my (hash-refn cursors 'orc 'point) at the REPL. Haskellers should indeed feel kind of bad about :(

Name: Anonymous 2011-02-07 0:51

>>83
GHCI.

Name: Anonymous 2011-02-07 7:34

>>86
dont allow side effects

Name: Anonymous 2011-02-07 7:38

>>87
Nomads

Name: Anonymous 2011-02-07 11:41

Imagine a giant cudder flying towards your dotted pair, and there's nothing you can do about it. And you're like "Oh man, I'm gonna have to cons this thing", and you brace yourself to cons this giant cudder. But then, at the last moment, it changes trajectory and hits you in the car. You think to yourself "Well, at least I got that out of the way", but then the giant cudder rears back and gets assigned to the car again, and again, and again. Eventually, this giant car is penetrating your dotted pair, and you begin to lose control over your memory management. That's when the giant cudder foldrs into a single value, causing your stack to overflow. Unable to move and at your most vulnerable, the giant cudder finally lodges itself in your list, where it rests uncomfortable for 4, maybe 5 hours. That's what using Lisp is like.

Name: Anonymous 2011-02-07 11:55

>>89
causing your stack to overflow.
That's what using Lisp is like.

U MENA HASKAL!

Name: Anonymous 2011-02-07 11:59

>>89
My favorite CP and an original take on it, too? Thank you, I enjoyed it thoroughly!

Name: Anonymous 2011-02-07 17:43

factorial n = case n of 1->1; _->n*factorial (n-1)

BEHOLD 7 MORE CHARACTERS !

Name: Anonymous 2011-02-07 20:14

>>92
All I'm beholding is the disturbing lack of [code] tags in your post.

Name: Anonymous 2011-02-08 0:20

>>93
I bet he even writes his code in notepad.

Name: Anonymous 2012-07-16 6:13

>>5
GLORIOUS

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