Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Scheme (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Review of standard forms and procedures == The language is formally defined in the standards R5RS (1998)<ref name="r5rs"/> and R6RS (2007).<ref name="r6rs"/> They describe standard "forms": keywords and accompanying syntax, which provide the control structure of the language, and standard procedures which perform common tasks. ===Standard forms=== This table describes the standard forms in Scheme. Some forms appear in more than one row because they cannot easily be classified into a single function in the language. Forms marked "L" in this table are classed as derived "library" forms in the standard and are often implemented as macros using more fundamental forms in practice, making the task of implementation much easier than in other languages. {| class="wikitable" |+ Standard forms in the language R5RS Scheme ! Purpose !! Forms |- | Definition || {{mono|define}} |- | Binding constructs || {{mono|lambda, do (L), let (L), let* (L), letrec (L)}} |- | Conditional evaluation || {{mono|if, cond (L), case (L), and (L), or (L)}} |- | Sequential evaluation || {{mono|begin (*)}} |- | Iteration || {{mono|lambda, do (L), named let (L)}} |- | Syntactic extension || {{mono|define-syntax, let-syntax, letrec-syntax, syntax-rules (R5RS), syntax-case (R6RS)}} |- | Quoting || {{mono|quote('), unquote(,), quasiquote(`), unquote-splicing(,@)}} |- | Assignment || {{mono|set!}} |- | Delayed evaluation || {{mono|delay (L)}} |} While <code>begin</code> is defined as a library syntax in R5RS, the expander must know about it to achieve the splicing function. In R6RS it is no longer a library syntax. ===Standard procedures=== The following two tables describe the standard procedures in R5RS Scheme. R6RS is far more extensive and a summary of this type would not be practical. Some procedures appear in more than one row because they cannot easily be classified into a single function in the language. {| class="wikitable" |+ Standard procedures in the language R5RS Scheme ! Purpose !! Procedures |- | Construction || {{mono|vector, make-vector, make-string, list}} |- | Equivalence predicates || {{mono|1=eq?, eqv?, equal?, string=?, string-ci=?, char=?, char-ci=?}} |- | [[Type conversion]] || {{mono|vector->list, list->vector, number->string, string->number, symbol->string, string->symbol, char->integer, integer->char, string->list, list->string}} |- | Numbers || {{mono|''See separate table''}} |- | Strings || {{mono|1=string?, make-string, string, string-length, string-ref, string-set!, string=?, string-ci=?, string<? string-ci<?, string<=? string-ci<=?, string>? string-ci>?, string>=? string-ci>=?, substring, string-append, string->list, list->string, string-copy, string-fill!}} |- | Characters || {{mono|1=char?, char=?, char-ci=?, char<? char-ci<?, char<=? char-ci<=?, char>? char-ci>?, char>=? char-ci>=?, char-alphabetic?, char-numeric?, char-whitespace?, char-upper-case?, char-lower-case?, char->integer, integer->char, char-upcase, char-downcase}} |- | Vectors || {{mono|make-vector, vector, vector?, vector-length, vector-ref, vector-set!, vector->list, list->vector, vector-fill!}} |- | Symbols || {{mono|symbol->string, string->symbol, symbol?}} |- | Pairs and lists || {{mono|pair?, cons, car, cdr, set-car!, set-cdr!, null?, list?, list, length, append, reverse, list-tail, list-ref, memq. memv. member, assq, assv, assoc, list->vector, vector->list, list->string, string->list}} |- | Identity predicates || {{mono|boolean?, pair?, symbol?, number?, char?, string?, vector?, port?, procedure?}} |- | Continuations || {{mono|call-with-current-continuation (call/cc), values, call-with-values, dynamic-wind}} |- | Environments || {{mono|eval, scheme-report-environment, null-environment, interaction-environment (optional)}} |- | Input/output || {{mono|display, newline, read, write, read-char, write-char, peek-char, char-ready?, eof-object? open-input-file, open-output-file, close-input-port, close-output-port, input-port?, output-port?, current-input-port, current-output-port, call-with-input-file, call-with-output-file, with-input-from-file(optional), with-output-to-file(optional)}} |- | System interface || {{mono|load (optional), transcript-on (optional), transcript-off (optional)}} |- | Delayed evaluation || {{mono|force}} |- | Functional programming || {{mono|procedure?, apply, map, for-each}} |- | Booleans || {{mono|boolean? not}} |} String and character procedures that contain "-ci" in their names perform case-independent comparisons between their arguments: upper case and lower case versions of the same character are taken to be equal. {| class="wikitable" |+ Standard numeric procedures in the language R5RS Scheme ! Purpose !! Procedures |- | Basic arithmetic operators || {{mono|+, -, *, /, abs, quotient, remainder, modulo, gcd, lcm, expt, sqrt}} |- | Rational numbers || {{mono|numerator, denominator, rational?, rationalize}} |- | Approximation || {{mono|floor, ceiling, truncate, round}} |- | Exactness || {{mono|inexact->exact, exact->inexact, exact?, inexact?}} |- | Inequalities || {{mono|1=<, <= , >, >=, =}} |- | Miscellaneous predicates || {{mono|zero?, negative?, positive? odd? even?}} |- | Maximum and minimum || {{mono|max, min}} |- | Trigonometry || {{mono|sin, cos, tan, asin, acos, atan}} |- | Exponentials || {{mono|exp, log}} |- | Complex numbers || {{mono|make-rectangular, make-polar, real-part, imag-part, magnitude, angle, complex?}} |- | Input-output || {{mono|number->string, string->number}} |- | Type predicates || {{mono|integer?, rational?, real?, complex?, number?}} |} Implementations of - and / that take more than two arguments are defined but left optional at R5RS.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)