samples.scm < Viivi Tutorial and References < Viivi's Cell < Entrance
The Viivi package file includes a small sample Scheme source code file
"samples.scm
".
The user can try it to be familiar with Viivi IDE operation.
:::::::::::::::::
:: samples.scm ::
:::::::::::::::::
1: ;; samples.scm
2:
3: ;; number
4: 30
5: 500
6: 10000000000000000000000000000000000000000193
7: 3.14159265358979
8: 7/31
9:
10: ;; arithmentcs
11: (+ 20 30)
12: (* 40 (+ 50 60) 70)
13: (+ 1/3 2/7 5/17)
14: (* 3+2i 7-3i)
15:
16: ;; variable
17: (define n 900)
18: (+ n 300)
19:
20: ;; character string
21: "This is a pen."
22:
23: ;; reverse the argument-string
24: (define reverse-input-string
25: (lambda (in-string)
26: (write
27: (list->string
28: (reverse
29: (string->list
30: in-string))))))
31:
32: (reverse-input-string "I Love The Scheme Programming Language!")
33:
34: ;; factorial
35: (define !
36: (lambda (n)
37: (if (= n 0)
38: 1
39: (* n (! (- n 1))))))
40:
41: (! 20)
42:
43: ;; factorial (Tail-Recursive version)
44: (define !-tail-recursive
45: (lambda (n result)
46: (if (= n 0)
47: result
48: (!-tail-recursive
49: (- n 1) (* n result)))))
50:
51: (!-tail-recursive 20 1)
52:
53: ;; end of file
54:
samples.scm < Viivi Simple Tutorial and Brief References < Viivi's Cell < Entrance
Exhibited on 2022/03/02
Copyright(C) 2003-2022 ilma <ilma@viivi.io> All rights reserved.