Home > Palm > Samples > Combination > Lisp
  Palm sample in Lisp


This is the Lisp version of our combination application. It's one of the Palm Samples.


You need LispMe (see tools section).

 Source code

Below is the .lisp file.

; Combination.lisp
; Palm
; LispMe

(define (factorial n)
  (if (<= n 1) 1 (* n (factorial (- n 1)))))

(define (combination n p)
  (/ (factorial n) (* (factorial (- n p)) (factorial p))))

(define (go)
  (let ((sock 4))
    (display "Combination > Palm > LispMe")
    (display "#0a")
    (display "#0a")
    (display "factorial(7) = ")
    (display (factorial 7))
    (display "#0a")
    (display "factorial(4) = ")
    (display (factorial 4))
    (display "#0a")
    (display "factorial(3) = ")
    (display (factorial 3))
    (display "#0a")
    (display "combination(7, 4) = ")
    (display (combination 7 4))
    (display "#0a")


LispMe is a mobile tool. If you love both Lisp and Palm devices, then that's the way to go! It runs directly on your mobile device.

Create a memo category named "LispMe" with Palm Desktop. This is where LispMe will look when you open a file.

Copy and Paste the source code above into a new memo in this LispMe category. Run HotSync. The source code will be stored in a ;Combination.lisp memo. Run LispMe and tap Ld to load the memo. To run the app, just enter (go) and tap Eval.

The core functions are : factorial, combination and go.

Note how functional programming can look weird if you're not used to it: + 7 4 (pre-fixed notation) means 7 + 4 (unfixed notation).

Next sample


[ Copyright © 2000- Eric Poncet - All rights reserved ]

[ Stages de musique ]

[ Stage de musique classique | Stage de musique baroque | Stage de musique de chambre | Stage de musique latine ]
[ Stage de jazz | Stage de musiques actuelles | Stage de funk | Stage de metal | Stage de pop | Stage de reggae | Stage de rock ]
[ Stage d'improvisation | Colonie musicale ]