Changeset 39490 in project
- Timestamp:
- 01/10/21 10:33:40 (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wiki/friendly-chicken
r30888 r39490 3 3 If you're a CHICKEN beginner, you come from another language or a different scheme implementation, there are a few things you might be wondering about, when you're first exposed to CHICKEN. This little tutorial shall help you to lower the barriers and highlight some little pitfalls so that your time with CHICKEN is more fun from the very beginning. 4 4 5 For a general introduction to CHICKEN, see [[man/4/Getting started|Getting started]]. 6 7 === The numeric tower 8 9 CHICKEN's core does not provide the full numeric tower. This might surprise you if you come from other scheme implementations, or 10 use CHICKEN to do your scheme homeworks. Don't worry, your homeworks are safe. It's easy to get the full tower through [[/egg/numbers|the numbers egg]]. 11 Simply install the egg and load it via '''require-extension''' or '''use'''. 12 13 Installation: 14 <enscript highligh="scheme"> 15 $ chicken-install numbers 16 </enscript> 17 18 Usage: 19 <enscript highlight="scheme"> 20 (use numbers) 21 22 (complex? 1.0+2.0i) 23 </enscript> 24 25 The important thing is that you '''use''' numbers. 26 27 === Where is my fold? 28 29 Since scheme is a lisp it offers quite a few useful procedures that operate on lists, such as '''fold''','''unfold''','''filter''' and many more. 30 You might have seen those in the examples of a tutorial, textbook or your scheme class. As the happy schemer, that you are, you instantly tried 31 them out in a fresh csi session, when you had to realize that CHICKEN doesn't seem to know them. 32 33 Again it's easy enough to get it. SRFI-1 comes as a core unit, which means that you don't need to install an egg. 34 35 <enscript highlight="scheme"> 36 (use srfi-1) 37 38 (filter odd? (iota 10)) 39 </enscript> 5 For a general introduction to CHICKEN, see [[man/5/Getting started|Getting started]]. 40 6 41 7 === UTF-8 … … 46 12 <enscript highlight="bash"> 47 13 CHICKEN 48 (c) 2008-20 14, The ChickenTeam14 (c) 2008-2020, The CHICKEN Team 49 15 (c) 2000-2007, Felix L. Winkelmann 50 Version 4.8.4 (rev 3d545a9) 51 linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ] 52 compiled 2014-02-06 on dantien (Linux) 16 Version 5.2.0 (rev 317468e4) 17 linux-unix-gnu-x86-64 [ 64bit dload ptables ] 53 18 19 Type ,? for help. 54 20 #;1> (string-length "λ") 55 21 2 … … 57 23 </enscript> 58 24 59 As you see (string-length)on the string containing the unicode-character returns 2 rather than 1.60 To fix this you need to install and use [[/egg/utf8|the utf8 egg]] .25 As you see {{string-length}} on the string containing the unicode-character returns 2 rather than 1. 26 To fix this you need to install and use [[/egg/utf8|the utf8 egg]] ({{chicken-install utf8}}). 61 27 62 See the transcript with utf8loaded:28 See the transcript with {{utf8}} loaded: 63 29 64 30 <enscript highlight="bash"> 65 31 CHICKEN 66 (c) 2008-20 14, The ChickenTeam32 (c) 2008-2020, The CHICKEN Team 67 33 (c) 2000-2007, Felix L. Winkelmann 68 Version 4.8.4 (rev 3d545a9) 69 linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ] 70 compiled 2014-02-06 on dantien (Linux) 34 Version 5.2.0 (rev 317468e4) 35 linux-unix-gnu-x86-64 [ 64bit dload ptables ] 71 36 72 #;1> (use utf8) 73 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/utf8.import.so ... 74 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/chicken.import.so ... 75 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/data-structures.import.so ... 76 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/extras.import.so ... 77 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/regex.import.so ... 78 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/irregex.import.so ... 79 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/ports.import.so ... 80 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/utf8-lolevel.import.so ... 81 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/lolevel.import.so ... 82 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/utf8.so ... 83 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/regex.so ... 84 ; loading /home/certainty/sys/opt/chickens/master/lib/chicken/7/utf8-lolevel.so ... 37 Type ,? for help. 38 #;1> (import utf8) 39 ; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.import.so ... 40 41 Note: re-importing already imported identifier: string-length 42 43 Note: re-importing already imported identifier: string-ref 44 45 Note: re-importing already imported identifier: string-set! 46 47 Note: re-importing already imported identifier: make-string 48 49 Note: re-importing already imported identifier: string 50 51 Note: re-importing already imported identifier: substring 52 53 Note: re-importing already imported identifier: string->list 54 55 Note: re-importing already imported identifier: list->string 56 57 Note: re-importing already imported identifier: string-fill! 58 59 Note: re-importing already imported identifier: write-char 60 61 Note: re-importing already imported identifier: read-char 62 63 Note: re-importing already imported identifier: display 64 65 Note: re-importing already imported identifier: print 66 67 Note: re-importing already imported identifier: print* 68 ; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.so ... 69 ; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/regex.so ... 70 ; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8-lolevel.so ... 85 71 #;2> (string-length "λ") 86 72 1 87 #;3>88 73 </enscript> 74 75 Nevermind the notes -- they are just an indication that procedures from the {{utf8}} egg are redefining the procedures from the {{scheme}} module. 76 89 77 90 78 === Load useful libraries and units in csi automatically 91 79 92 If you find yourself using these libraries alot you might want to have '''csi'''load them whenever you start it up.93 This can easily be done by adding them to your '''$HOME/.csirc'''.80 If you find yourself using these libraries alot you might want to have {{csi}} load them whenever you start it up. 81 This can easily be done by adding them to your {{$HOME/.csirc}}. 94 82 95 A sample csircmight look like this:83 A sample {{.csirc}} might look like this: 96 84 97 85 <enscript highlight="scheme"> 98 ( use numbersutf8 srfi-1 srfi-13)86 (import utf8 srfi-1 srfi-13) 99 87 </enscript> 88 89 Note that you have to install {{utf8}}, {{srfi-1}} and {{srfi-13}} via {{chicken-install}}. 100 90 101 91 … … 104 94 The following lists a few of them: 105 95 96 106 97 ==== Eggs 107 * [[/egg/numbers|numbers]] - Full numeric tower 108 * [[/egg/utf8|UTF8]] - Make string procedures utf8 aware 98 * [[/egg/utf8|UTF8]] - Make string procedures utf8 aware 99 * [[/egg/srfi-1|SRFI-1]] - List procedures 100 * [[/egg/srfi-13|SRFI-13]] - String procedures 101 * [[/egg/srfi-69|SRFI-69]] - Hashtables 109 102 110 103 ==== Units 111 104 (You don't need to chicken-install these) 112 * [[/manual/Unit srfi-1|SRFI-1]] - List procedures 113 * [[/manual/Unit srfi-13|SRFI-13]] - String procedures 114 * [[/manual/Unit srfi-69|SRFI-69]] - Hashtables 115 * [[/manual/Unit irregex|irregex]] - Regular expressions 105 * [[/manual/Module (chicken irregex)|irregex]] - Regular expressions 106 116 107 117 108 === Happy Hacking 118 109 119 110 I hope this little guide helps you to start your CHICKEN journey without too many surprises. 120 Have fun hacking ... .111 Have fun hacking ...
Note: See TracChangeset
for help on using the changeset viewer.