Next: , Up: Hello Guile!   [Contents][Index]


2.1 Running Guile Interactively

In its simplest form, Guile acts as an interactive interpreter for the Scheme programming language, reading and evaluating Scheme expressions the user enters from the terminal. Here is a sample interaction between Guile and a user; the user’s input appears after the $ and [email protected](guile-user)> prompts:

$ guile
[email protected](guile-user)> (+ 1 2 3)                ; add some numbers
$1 = 6
[email protected](guile-user)> (define (factorial n)    ; define a function
                       (if (zero? n) 1 (* n (factorial (- n 1)))))
[email protected](guile-user)> (factorial 20)
$2 = 2432902008176640000
[email protected](guile-user)> (getpwnam "root")        ; look in /etc/passwd
$3 = #("root" "x" 0 0 "root" "/root" "/bin/bash")
[email protected](guile-user)> C-d
$