Changeset 39490 in project


Ignore:
Timestamp:
01/10/21 10:33:40 (2 weeks ago)
Author:
Mario Domenech Goulart
Message:

/friendly-chicken: adapt to C5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/friendly-chicken

    r30888 r39490  
    33If 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.
    44
    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>
     5For a general introduction to CHICKEN, see [[man/5/Getting started|Getting started]].
    406
    417=== UTF-8
     
    4612<enscript highlight="bash">
    4713CHICKEN
    48 (c) 2008-2014, The Chicken Team
     14(c) 2008-2020, The CHICKEN Team
    4915(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)
     16Version 5.2.0 (rev 317468e4)
     17linux-unix-gnu-x86-64 [ 64bit dload ptables ]
    5318
     19Type ,? for help.
    5420#;1> (string-length "λ")
    55212
     
    5723</enscript>
    5824
    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]].
     25As you see {{string-length}} on the string containing the unicode-character returns 2 rather than 1.
     26To fix this you need to install and use [[/egg/utf8|the utf8 egg]] ({{chicken-install utf8}}).
    6127
    62 See the transcript with utf8 loaded:
     28See the transcript with {{utf8}} loaded:
    6329
    6430<enscript highlight="bash">
    6531CHICKEN
    66 (c) 2008-2014, The Chicken Team
     32(c) 2008-2020, The CHICKEN Team
    6733(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)
     34Version 5.2.0 (rev 317468e4)
     35linux-unix-gnu-x86-64 [ 64bit dload ptables ]
    7136
    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 ...
     37Type ,? for help.
     38#;1> (import utf8)
     39; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.import.so ...
     40
     41Note: re-importing already imported identifier: string-length
     42
     43Note: re-importing already imported identifier: string-ref
     44
     45Note: re-importing already imported identifier: string-set!
     46
     47Note: re-importing already imported identifier: make-string
     48
     49Note: re-importing already imported identifier: string
     50
     51Note: re-importing already imported identifier: substring
     52
     53Note: re-importing already imported identifier: string->list
     54
     55Note: re-importing already imported identifier: list->string
     56
     57Note: re-importing already imported identifier: string-fill!
     58
     59Note: re-importing already imported identifier: write-char
     60
     61Note: re-importing already imported identifier: read-char
     62
     63Note: re-importing already imported identifier: display
     64
     65Note: re-importing already imported identifier: print
     66
     67Note: 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 ...
    8571#;2> (string-length "λ")
    86721
    87 #;3>
    8873</enscript>
     74
     75Nevermind the notes -- they are just an indication that procedures from the {{utf8}} egg are redefining the procedures from the {{scheme}} module.
     76
    8977
    9078=== Load useful libraries and units in csi automatically
    9179
    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'''.
     80If you find yourself using these libraries alot you might want to have {{csi}} load them whenever you start it up.
     81This can easily be done by adding them to your {{$HOME/.csirc}}.
    9482
    95 A sample csirc might look like this:
     83A sample {{.csirc}} might look like this:
    9684
    9785<enscript highlight="scheme">
    98 (use numbers utf8 srfi-1 srfi-13)
     86(import utf8 srfi-1 srfi-13)
    9987</enscript>
     88
     89Note that you have to install {{utf8}}, {{srfi-1}} and {{srfi-13}} via {{chicken-install}}.
    10090
    10191
     
    10494The following lists a few of them:
    10595
     96
    10697==== 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
    109102
    110103==== Units
    111104(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
    116107
    117108=== Happy Hacking
    118109
    119110I hope this little guide helps you to start your CHICKEN journey without too many surprises.
    120 Have fun hacking ....
     111Have fun hacking ...
Note: See TracChangeset for help on using the changeset viewer.