codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
;; QR card for scheme ;; (c) 2011 Aaron Lahman ;; r5rs load module (load {filename-string}) ;; variables (define {var} {expr..}) (let (({var} {expr})..) {expr..}) (let* ..) ;in sequence (letrec ..) ;recursive procs ;; procedures (define ({proc} {args..}) {body..}) (lambda ({args..}) {body..}) ;; control flow (if {test} {true-expr} {false-expr}) (cond ({test} {body..}).. ({test} => {thunk}).. (else {body..})) (case {expr} (({keys..}) {body..}).. (else {body..})) (do (({var} {init} {step})..) ({test} {exit-body..}) {body..}) ;named let: (let {name} (({v} {e})..) {e..}) ;; data types (boolean? {e}) (pair? {e}) (symbol? {e}) (number? {e}) (char? {e}) (vector? {e}) (port? {e}) (procedure? {e}) ;equality (eq? {a} {b}) ;ref equality (eqv? {a} {b}) ;number, string (equal? {a} {b}) ;list contents ;; operators + - * / (quotient a b) ;integer division (modulo a b) ;remainder (= {nums..}) ;numeric equality ;; logic #t #f (and {expr..}) ;short circuit (or {expr..}) ;short circuit (not {expr}) ;; characters #\a #\1 #\newline #\space (char=? {a} {b}) ; <, >, <=, >= (char-ci=? {a} {b}) (char->integer {ch}) (integer->char {i}) ;; strings "hello" (string-length {s}) (string-ref {s} {i}) (string=? {a} {b}) ; <, >, <=, >= (string-ci=? {a} {b}) (substring {s} {start} {end}) (string-append {s..}) (string-set! {s} {i} {ch}) (string-copy {s}) ;; symbols (symbol->string {sym}) (string->symbol {s}) ;; list/pair () (0 1 2) (a . b) (cons {h} {t}) (car {p}) (cdr {p}) (set-car! {p} {h}) (set-cdr! {p} {t}) (null? {o}) (list? {o}) (list {expr..}) (length {o}) (append {lst..}) (reverse {lst}) (list-ref {lst} {i}) ;; vector #() #(0 1 2) (make-vector {len}) (vector {expr..}) (vector-length {v}) (vector-ref {v} {i}) (vector-set! {v} {i} {expr}) (vector->list {v}) (list->vector {lst}) ;; input (input-port? {obj}) (current-input-port) (open-input-file {filename}) (close-input-port {port}) (call-with-input-file {filename} {thunk}) (read {?port}) (read-char {?port}) (peek-char {?port}) (eof-object? {obj}) (char-read? {?port}) ;; output (output-port? {obj}) (current-output-port) (open-output-file {filename}) (close-output-port {port}) (call-with-output-file {filename} {thunk}) (write {obj} {?port}) (display {obj} {?port}) (write-char {ch} {?port}) (newline {?port}) ;; quoting '{e} (quote {e}) `{e} (quasiquote {e}) ,{e} (unquote {e}) ,@{e} (unquote-splicing {e}) ;; control functions (delay {e}) (force {promise}) (call-with-current-continuation {proc}) (map {proc} {lst..}) (for-each {proc} {lst..}) ;; macros (let-syntax (({keyword} {transformer})..) {body..}) (define-syntax {keyword} {transformer}) ;transformer (syntax-rules ({literals..}) ({pattern} {template})..) ;patterns x ;variable x ... ;repetition {pat} ... ;repeated pattern
Private
[
?
]
Run code
Submit