Code conventions for the SALSA! sourcesThis document contains the code conventions for the files written in SALSA! Source example/*
* This source file contains an example program written in SALSA!
*/
;; f :: int -> int
(define (f n)
(do (+ 2 3) ; This value is neglected
(* 3 4) ; also this one, because
3 ; the value of a do expression
(let (r (* n 2)) ; is the value of the last exp (this one in this example)
(case ((= r 0) n)
((> r 10) r)
(else (* r 3))))))
/*
* This source file contains an example program written in SALSA!
*/
;; fib-aux :: int int int -> int
(define (fib-aux n acc)
(if (= n 1)
acc
(fib-aux (- n 1) (* n acc) )))
;; fib :: int -> int
(define (fib n)
(if (< n 0)
"Error"
(fib-aux n 1)))
(fib 6) ; calling fib with 6
/*
* This source file contains an example program written in SALSA!
*
*/
;; greetings :: int -> string
(define (greetings x)
(case ((< x 12) "Good morning")
((< x 19) "Good evening")
((< x 24) "Good night")
(else "Are you in Pluto or what?")))
(greetings 20) ; calling greetings with 20
|