mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-26 15:13:56 +00:00
CHICKEN.html.markdown: adapt to CHICKEN 5 (#4154)
This change adapt the instructions to CHICKEN 5. Before it covered CHICKEN 4, which is an outdated version.
This commit is contained in:
parent
6a11164757
commit
353f9fca40
@ -362,8 +362,6 @@ sqr ;; => #<procedure (sqr x)>
|
|||||||
;; The CHICKEN core is very minimal, but additional features are provided by library extensions known as Eggs.
|
;; The CHICKEN core is very minimal, but additional features are provided by library extensions known as Eggs.
|
||||||
;; You can install Eggs with 'chicken-install <eggname>' command.
|
;; You can install Eggs with 'chicken-install <eggname>' command.
|
||||||
|
|
||||||
;; 'numbers' egg provides support for full numeric tower.
|
|
||||||
(require-extension numbers)
|
|
||||||
;; complex numbers
|
;; complex numbers
|
||||||
3+4i ;; => 3+2i
|
3+4i ;; => 3+2i
|
||||||
;; Supports fractions without falling back to inexact flonums
|
;; Supports fractions without falling back to inexact flonums
|
||||||
@ -375,12 +373,12 @@ sqr ;; => #<procedure (sqr x)>
|
|||||||
(numerator 2/3) ;; => 2
|
(numerator 2/3) ;; => 2
|
||||||
|
|
||||||
;; 'utf8' provides unicode support
|
;; 'utf8' provides unicode support
|
||||||
(require-extension utf8)
|
(import utf8)
|
||||||
"\u03BBx:(\u03BC\u0251.\u0251\u2192\u0251).xx" ;; => "λx:(μɑ.ɑ→ɑ).xx"
|
"\u03BBx:(\u03BC\u0251.\u0251\u2192\u0251).xx" ;; => "λx:(μɑ.ɑ→ɑ).xx"
|
||||||
|
|
||||||
;; 'posix' provides file I/O and lots of other services for unix-like operating systems
|
;; 'posix' provides file I/O and lots of other services for unix-like operating systems
|
||||||
;; Some of the functions are not available in Windows system,
|
;; Some of the functions are not available in Windows system,
|
||||||
;; See http://wiki.call-cc.org/man/4/Unit%20posix for more details
|
;; See http://wiki.call-cc.org/man/5/Module%20(chicken%20file%20posix) for more details
|
||||||
|
|
||||||
;; Open a file to append, open "write only" and create file if it does not exist
|
;; Open a file to append, open "write only" and create file if it does not exist
|
||||||
(define outfn (file-open "chicken-hen.txt" (+ open/append open/wronly open/creat)))
|
(define outfn (file-open "chicken-hen.txt" (+ open/append open/wronly open/creat)))
|
||||||
@ -396,14 +394,14 @@ sqr ;; => #<procedure (sqr x)>
|
|||||||
|
|
||||||
;; CHICKEN also supports SRFI (Scheme Requests For Implementation) extensions
|
;; CHICKEN also supports SRFI (Scheme Requests For Implementation) extensions
|
||||||
;; See 'http://srfi.schemers.org/srfi-implementers.html" to see srfi's supported by CHICKEN
|
;; See 'http://srfi.schemers.org/srfi-implementers.html" to see srfi's supported by CHICKEN
|
||||||
(require-extension srfi-1) ;; list library
|
(import srfi-1) ;; list library
|
||||||
(filter odd? '(1 2 3 4 5 6 7)) ;; => (1 3 5 7)
|
(filter odd? '(1 2 3 4 5 6 7)) ;; => (1 3 5 7)
|
||||||
(count even? '(1 2 3 4 5)) ;; => 2
|
(count even? '(1 2 3 4 5)) ;; => 2
|
||||||
(take '(12 24 36 48 60) 3) ;; => (12 24 36)
|
(take '(12 24 36 48 60) 3) ;; => (12 24 36)
|
||||||
(drop '(12 24 36 48 60) 2) ;; => (36 48 60)
|
(drop '(12 24 36 48 60) 2) ;; => (36 48 60)
|
||||||
(circular-list 'z 'q) ;; => z q z q ...
|
(circular-list 'z 'q) ;; => z q z q ...
|
||||||
|
|
||||||
(require-extension srfi-13) ;; string library
|
(import srfi-13) ;; string library
|
||||||
(string-reverse "pan") ;; => "nap"
|
(string-reverse "pan") ;; => "nap"
|
||||||
(string-index "Turkey" #\k) ;; => 3
|
(string-index "Turkey" #\k) ;; => 3
|
||||||
(string-every char-upper-case? "CHICKEN") ;; => #t
|
(string-every char-upper-case? "CHICKEN") ;; => #t
|
||||||
@ -448,7 +446,7 @@ sqr ;; => #<procedure (sqr x)>
|
|||||||
; 9. Modules
|
; 9. Modules
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;; Also See http://wiki.call-cc.org/man/4/Modules
|
;; Also See http://wiki.call-cc.org/man/5/Modules
|
||||||
|
|
||||||
;; The 'test' module exports a value named 'hello' and a macro named 'greet'
|
;; The 'test' module exports a value named 'hello' and a macro named 'greet'
|
||||||
(module test (hello greet)
|
(module test (hello greet)
|
||||||
@ -509,11 +507,11 @@ sqr ;; => #<procedure (sqr x)>
|
|||||||
|
|
||||||
```
|
```
|
||||||
## Further Reading
|
## Further Reading
|
||||||
* [CHICKEN User's Manual](http://wiki.call-cc.org/man/4/The%20User%27s%20Manual).
|
* [CHICKEN User's Manual](https://wiki.call-cc.org/manual).
|
||||||
* [R5RS standards](http://www.schemers.org/Documents/Standards/R5RS)
|
* [R5RS standards](http://www.schemers.org/Documents/Standards/R5RS)
|
||||||
|
|
||||||
|
|
||||||
## Extra Info
|
## Extra Info
|
||||||
|
|
||||||
* [For programmers of other languages](http://wiki.call-cc.org/chicken-for-programmers-of-other-languages)
|
* [For programmers of other languages](https://wiki.call-cc.org/chicken-for-programmers-of-other-languages)
|
||||||
* [Compare CHICKEN syntax with other languages](http://plr.sourceforge.net/cgi-bin/plr/launch.py)
|
* [Compare CHICKEN syntax with other languages](http://plr.sourceforge.net/cgi-bin/plr/launch.py)
|
||||||
|
Loading…
Reference in New Issue
Block a user