GNU Guile
Implementation of programming language LispGNU Guile (Guile stands for Gnu’s Ubiquitous Interactive Language for Extension) is an interpreter/virtual machine for Lisp which implements Scheme dialect. It was first released in 1993.
GNU Guile was developed to become a scripting language to replace Tcl.
Guile includes modularized extensions for POSIX system calls, APL array functionality, and others, packaged as an object library. “Libguile” allows Guile to be embedded in other programs and used as an interface for other languages.
GNU Guile logo
Examples:
Hello, World!:
Example for versions JScheme 7.2, MIT/GNU Scheme 7.7.9, guile 1.8.5Printing a message is a side effect of this command. Depending on the chosen implementation, the command will return either the message printed, or Unspecified return value.
(write "Hello, World!")
Factorial:
Example for versions JScheme 7.2, MIT/GNU Scheme 7.7.9, guile 1.8.5This example uses tail-recursive factorial calculation. Note that GNU Guile and MIT/GNU Scheme print correct result, while JScheme has values of factorial starting with 13! wrong due to overflow.
(define (factorial x)
(if (< x 2)
1
(* x (factorial (- x 1)))))
(do ((i 0 (+ i 1)))
((> i 16))
(display (string-append (number->string i) "! = "))
(display (number->string (factorial i)))
(newline))
Fibonacci numbers:
Example for versions JScheme 7.2, MIT/GNU Scheme 7.7.9, guile 1.8.5This example uses recursive definition of Fibonacci numbers.
(define (fibonacci x)
(if (< x 2)
x
(+ (fibonacci (- x 1)) (fibonacci (- x 2)))))
(do ((i 1 (+ i 1)))
((> i 16))
(display (string-append (number->string (fibonacci i)) ", ")))
(display "...")
(newline)
Comments
]]>blog comments powered by Disqus
]]>