Use SchemeProgramVoice: Hello world. Open your editor, create a file named hello. SS, and save the following text:
; Hello. SS (Import (rnrs) (begin; display "Hello world.") (newline ))
The first line is a comment. Scheme ignores the semicolon (;) and text content after it.
Begin is transmittedSubordinate statement segment(Subform) a method of sequence. In the preceding example, there are two sub-statement segments. Call the display processing function in section 1st: Output its real parameter (string "Hello world.") to the console (or "standard output "). Section 2nd is the call of the newline processing function: A carriage return is output.
To run the program, open the ironscheme console and enter:
(Load "E: \ work \ hello. SS ")
Scheme will execute the content in hello. SS and OutputHello world.
Followed by a carriage return.
In "Higher-order functions: functions used as parameters, functions generated, and anonymous functions", use an anonymous function to calculate the square of a given number:
; Square. SS (Import (rnrs); defines the square function (define Square; anonymous function (lambda (x) (* X); calls the square function, then display (square 3) (newline) (Display (Square 4) (newline)
Result of executing the square. SS content
In the "FP" shared by Abruzzi, the list parameters are accumulated using the apply processing function:
; List. SS (Import (rnrs) (define (sum Arglist) (apply + Arglist) (define P' (1 2 3 4 5 6) (Display (sum p )) (newline)
AboveCodeNote: use single quotes to specify the list. You can also write it as follows:
(List 1 2 3 4 5 6)
Refer:
Teach Yourself scheme in fixnum days)
(End)