Changeset 32574 in project


Ignore:
Timestamp:
07/11/15 01:10:13 (4 years ago)
Author:
Mario Domenech Goulart
Message:

chicken-for-php-programmers (wiki): minor fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/chicken-for-php-programmers

    r32287 r32574  
    55This is a work in progress, I will try to work on as frequently as possible (mostly on sunday).  In the meantime, feel free to help me by expanding it, correcting (english is not my native language) and/or by commenting on what I have done so far.
    66
    7 CHICKEN is an implementation of the Scheme programming language which, in turn is a member of the Lisp family of languages.  More information about this on the http://schemers.org/ website.
     7CHICKEN is an implementation of the Scheme programming language which, in turn is a member of the Lisp family of languages.  More information about this on the [[http://schemers.org/|http://schemers.org/]] website.
    88
    99== Syntax
     
    4545Is represented in scheme as:
    4646<enscript highlight=scheme>
    47 (- (+ 3 5)(* 12 2))
     47(- (+ 3 5) (* 12 2))
    4848</enscript>
    4949
    5050== Variables
    5151
    52 Like PHP, scheme does not type variables.  If you assign $var to a string, it is a string.  You re-assign it to 3, it become a number.
     52Like PHP, scheme does not type variables.  If you assign {{$var}} to a string, it is a string.  You re-assign it to {{3}}, it become a number.
    5353
    5454However, it should be noted that Scheme is much stricter when dealing with types. In PHP, you can usually omit typecasts, intermixing data of different types:
     
    5757</enscript>
    5858
    59 Is in Scheme it would cause an error, and you have to expicitly convert a string to a number:
     59Is in Scheme it would cause an error, and you have to explicitly convert a string to a number:
    6060<enscript highlight=scheme>
    6161(+ 10 (string->number "5"))
     
    6565=== Booleans
    6666
    67 TRUE, in Scheme, is noted #t while FALSE is noted #f.
    68 Unlike PHP, all Scheme values are considered to be true (#t) except #f itself, including zero (0), the empty string and others empty structures.
     67TRUE, in Scheme, is noted {{#t}} while FALSE is noted {{#f}}.
     68Unlike PHP, all Scheme values are considered to be true ({{#t}}) except {{#f}} itself, including zero ({{0}}), the empty string and other empty structures.
    6969
    7070<enscript highlight=scheme>
     
    7676All type of numbers are supported by CHICKEN, including real, complex and rational, natively (without resorting to external libraries). 
    7777
    78 Number can be expressed in binary, octal, decimal or hexadecimal notation by using the prefixs #b for binary, #o for octal, #d for decimal and #x for hexadecimal.  Unprefixed number are deicmal by default (so 21 and #d21 are the same)
     78Number can be expressed in binary, octal, decimal or hexadecimal notation by using the prefixs {{#b}} for binary, {{#o}} for octal, {{#d}} for decimal and {{#x}} for hexadecimal.  Unprefixed numbers are decimal by default (so {{21}} and {{#d21}} are the same).
    7979
    8080<table>
     
    8888=== Strings
    8989
    90 Scheme support a vast array of operations on string, including changing case, splitting, extracting substring and regular expressions based searching and replacing
     90Scheme support a vast array of operations on string, including changing case, splitting, extracting substring and regular expressions based searching and replacing.
    9191
    9292==== Exploding and imploding
     
    108108</enscript>
    109109
    110 Please note that the functions string-intersperse and string-split are in the extras unit, so if you are compiling a program, you will need to add this in the beginning of your code:
     110Please note that the functions {{string-intersperse}} and {{string-split}} are in the {{data-structures}} unit, so if you are compiling a program, you will need to add this in the beginning of your code:
    111111<enscript highlight=scheme>
    112 (use extras)
     112(use data-structures)
    113113</enscript>
    114114
     
    130130The base data structure of PHP is the array.  In Scheme it is the list.
    131131
    132 However, lists in Scheme are not as versatile as PHP arrays: lists in Scheme are best used for data that is accessed sequentially. So Scheme provides several other data types: vectors (arrays in a usual sense, allowing with a random access by an integer number) and hashtables (allow to access elements by any key).
     132However, lists in Scheme are not as versatile as PHP arrays: lists in Scheme are best used for data that is accessed sequentially. So Scheme provides several other data types: vectors (arrays in a usual sense, allowing with a random access by an integer number) and hash tables (allow to access elements by any key).
Note: See TracChangeset for help on using the changeset viewer.