File: functions.scm

package info (click to toggle)
gnumeric 1.4.3-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 71,576 kB
  • ctags: 28,555
  • sloc: ansic: 282,333; xml: 45,788; sh: 8,479; makefile: 3,119; yacc: 1,129; lisp: 200; perl: 173; python: 86
file content (73 lines) | stat: -rw-r--r-- 1,265 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;;;;;;;;;;;;;;;;;;;;;;;;
;; Ariel Rios         ;;
;; ariel@arcavia.com  ;;
;;;;;;;;;;;;;;;;;;;;;;;;

;; Licensed under GPL
;; Copyright 1999-2000 Ariel Rios

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;fibonacci function
;;Usage: =FIBO(number)
;;Calculates the fibonacci number of number.

(define (fibo k)
  (let ((n (value-get-as-int k)))
    (letrec ((fibof
	      (lambda (n a b)
		(if (<= n 2)
		    b
		    (fibof (- n 1) b (+ a b))))))
      (value-new-float (fibof n 1 1)))))

(register-function 
"fibo" "f"
"@FUNCTION=FIBO
@SYNTAX=FIBO(num)
@DESCRIPTION=Returns the fibonnacci computation for number."
"Guile"
fibo)

;;;;;;;;;;;;proof

;(define (test n)
;  1)

;(register-function
;"test" "a"
;"@FUNCTION=TEST
;@SYNTAX=TEST(num)
;@DESCRIPTION=test"
;test)

;; Guile-gtk example use with care!

;(use-modules (gtk gtk))  
                  
;(define (ggtest n)
;(call-with-current-continuation
; (lambda(val)
; (let ((window (gtk-window-new 'toplevel))
;       (calendar (gtk-calendar-new)))
; (gtk-container-add window calendar)
; (gtk-widget-show-all window)
; (gtk-standalone-main window)

;(break n)))))


;(register-function
;"ggtest" "f"
;"@FUNCTION=GGTEST
;@SYNTAX=GGTEST(num)
;@DESCRIPTION=Guile-gtk test"
;"Guile"
;ggtest)