From 85a58c42c49ef3e385fc68a673071fb0c1c3c7c5 Mon Sep 17 00:00:00 2001 From: Carl Sorensen Date: Wed, 23 Dec 2009 21:50:12 -0700 Subject: [PATCH] Doc: Extending -- Add Scheme conditionals --- Documentation/extending/scheme-tutorial.itely | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Documentation/extending/scheme-tutorial.itely b/Documentation/extending/scheme-tutorial.itely index db7c563ef1..2407c22f1c 100644 --- a/Documentation/extending/scheme-tutorial.itely +++ b/Documentation/extending/scheme-tutorial.itely @@ -545,8 +545,45 @@ guile> (let ((x 2) (y 3) (z 4)) (display (+ x y)) (display (- z 4)) @unnumberedsubsubsec if +Scheme has an @code{if} procedure: + +@example +(if test-expression true-expression false-expression) +@end example + +@var{test-expression} is an expression that returns a boolean +value. If @var{test-expression} returns @code{#t}, the if +procedure returns the value of @var{true-expression}, otherwise +it returns the value of @var{false-expression}. + +@lisp +guile> (define a 3) +guile> (define b 5) +guile> (if (> a b) "a is greater than b" "a is not greater than b") +"a is not greater than b" +@end lisp + @unnumberedsubsubsec cond +Another conditional procedure in scheme is @code{cond}: + +@example +(cond (test-expression-1 result-expression-sequence-1) + (test-expression-2 result-expression-sequence-2) + ... + (test-expression-n result-expression-sequence-n)) +@end example + +For example: + +@lisp +guile> (define a 6) +guile> (define b 8) +guile> (cond ((< a b) "a is less than b") +... ((= a b) "a equals b") +... ((> a b) "a is greater than b")) +"a is less than b" +@end lisp @node Scheme in LilyPond @section Scheme in LilyPond -- 2.39.5