Class | Global |
Name | eval |
Arguments | [Scheme expression] |
Accesses the Scheme read-eval-print-loop. If called without arguments, presents the Scheme prompt "%%", otherwise evaluates the rest of the line as if it were a Scheme expression. Sib-pair macro variables and functions are stored within the Scheme environment, and so can be read and written to.
For fuller documentation of other Scheme commands, see the Scheme standard: Standard Revised^5 Report on the Algorithmic Language Scheme (R5RS). The Sib-pair Scheme interpreter is fairly minimal - it implements characters as single-character strings, and lacks vectors. The types of numbers are long integers and double precision reals. Basic macro functionality (define-macro) is also provided. Aside from this, most R5RS examples work without problems (the interpreter is a port of Minischeme/Tinyscheme to Fortran 95). Interfaces to two graphic libraries are also implemented (see below).
Scheme keywords:
< | Numerically less than |
<= | Numerically less than or equal |
= | Numerically equal |
> | Numerically greater than |
>= | Numerically greater than or equal to |
- | Integer subtraction |
/ | Integer division |
* | Integer multiplication |
+ | Integer addition |
abs | Absolute value |
and | Logical and |
append | Append to end of list |
apply | Apply function to list |
apropos | List matching functions |
assoc | Find matching pair in an "alist" (list of paired values) using equal? |
assq | Find matching pair in an "alist" using eq? |
assv | Find matching pair in an "alist" using eqv? |
atom? | Is a simple number or string? |
begin | Start a block |
boolean? | Is a boolean? |
car | First element of pair or list |
cdr | Remainder of pair or list |
caar | First element of first element of pair or list |
cadr | Und so weiter |
cdar | |
cddr | |
caaar | |
cdddr | |
caadr | |
cadar | |
caddr | |
cdaar | |
cdadr | |
cddar | |
call/cc | |
call-with-current-continuation | |
case | Conditional branching |
char<? | Is char lexicographically less? |
char>? | Is char lexicographically greater? |
char<=? | Is char lexicographically less than or equal? |
char>=? | Is char lexicographically greater than or equal? |
char-alphabetic? | Is char alphabetic? |
char-ci<? | Is case-insensitive char lexicographically less? |
char-ci>? | Is case-insensitive char lexicographically greater? |
char-ci<=? | Is case-insensitive char lexicographically less than or equal? |
char-ci>=? | Is case-insensitive char lexicographically greater than or equal? |
char-numeric? | Is char a digit? |
char-whitespace? | Is char a tab, space, CR, NL, HR? |
char->integer | Return ASCII code |
char-downcase | Return lower case |
char-upcase | Return upper case |
closure? | Is a closure |
cond | Conditional branching |
cons | Create a Lisp pair of elements |
cons-stream | |
current-second | Return seconds since epoch |
define | Define a variable or function |
delay | |
display | Print a variable or function |
do | Looping construct |
else | |
eq? | |
equal? | |
eqv? | |
error | Print an error message |
eval | Evaluate a SEXPR (Scheme expression) |
even? | Test if even |
exact->inexact | Cast to real |
exit | Exit Sib-pair completely |
expt | Integer exponentiation |
force | |
for-each | Like map, but used for side-effects only |
format | Print formatted data |
gc | Force a garbage collection |
gcd | Greatest common divisor |
gensym | Create a new unique symbol |
get-closure-code | |
help | Minimal information about Scheme |
if | Conditional branching |
inexact->exact | Cast to integer |
integer? | Is an integer |
integer->char | Return character for given ASCII code |
lambda | Function |
lcm | Least common multiple |
length | Gives length of a list |
let | Declare a local variable |
let* | |
letrec | |
list | Create a list |
list? | Test if a list? |
list-ref | Gives Nth element of a list |
list-tail | Drops the first k elements of a list |
ls | List Sib-pair variables |
macro | |
make-list | Create a list of given length |
make-string | Create a string of given length |
map | Apply a function to each element of a list in turn |
max | Maximum of arguments |
member | Test if present in a list |
memq | Test if present in a list using equal? |
memv | Test if present in a list using eqv? |
min | Minimum of arguments |
modulo | Give modulo |
negative? | Test if negative integer |
newline | Print a newline |
new-segment | |
not | Logical negation |
null? | Test if a null |
number? | Test if an integer number |
number->string | Convert from number to string |
odd? | Test if odd |
or | Logical or |
pair? | Test if a Lisp pair |
positive? | Test if a positive integer |
print-width | |
procedure? | Is a function? |
quasiquote | Allow some of quoted expression to evaluate |
quit | Leave the Scheme interpreter |
quote | Quoted expression left unevaluated |
quotient | Integer division |
random | A random integer from U(1, N) |
read | |
read-line | Read one line of input from standard input or file |
remainder | Remainder |
reverse | Reverse ordering of a list |
run | Run a Sib-pair command |
set! | Set the contents of an existing variable |
set-car! | Set contents of first element of pair or list |
set-cdr! | Set contents of rest of pair or list |
sqrt | Integer square root |
string? | Is argument a string? |
string=? | Are strings equal? |
substring? | Is string 1 a substring of string 2? |
string<? | Is string lexicographically less? |
string>? | Is string lexicographically greater? |
string<=? | Is string lexicographically less than or equal? |
string>=? | Is string lexicographically greater than or equal? |
string-append | Concatenate strings |
string-length | Length of argument string |
string-ref | Get kth character from string |
string-set! | Set the value of a substring |
string-split | Split a string into a list of words |
string->number | Convert from a string to a number |
string->symbol | Convert from a string to a symbol |
substring | Get the value of a substring |
symbol? | Is a symbol? |
symbol->string | Convert from a symbol to a string |
system | Passes commands to the operating system |
unquote | |
unquote-splicing | |
write | |
zero? | Test if equal to zero |
The Sib-pair specific builtin commands that for example allowing access to locus data:
apropos <str> | lists commands containing that string. |
help | Information about this Scheme implementation. |
isatty? <fil> | test if interactive session. |
file-exists? <fil> | test file. |
file-list [<dir>] | list files in directory (Posix). |
file-delete <fil> | delete file. |
open-input-file <fil> | open a port. |
close-input-port <port> | close a port. |
read-line [<port>] | reads in next line from stdin or open file. |
format <port> "{~[:num:][@][ASD~%]}" <args>... | formatted output. |
regexp <expr> <str> | searches for regular expression in string. |
string-split <str> [<sep>] | splits string on white space or optional char. |
substring? <sub> <str> | returns start of substring in string. |
system <cmd> | passes command to shell. |
getenv <nam> | returns value of environment variable. |
date | returns current date and time. |
time | returns current time as number of seconds since epoch. |
environment-bound? <name> | test if symbol bound to a variable |
version | prints Sib-pair version. |
run <cmd> ... | runs a Sib-pair command. |
pass-command <cmd> ... | stores Sib-pair commands to the buffer for evaluation once you return to the usual Sib-pair prompt. |
Sib-pair locus dataset accessors:
ls [<typ>] | creates a list of locus names (of given type "adhmqx" | . |
nloci | returns total number of loci. | |
loc <index> | returns locus at that position in the locus list. | |
loc-set! <idx> <name> | set name of locus at that position in the locus list. | |
locord <loc> | returns position of a locus in the locus list. | |
locstat <loc> | returns last P-value for a locus. | |
locstat-init! <title> | initializes all locus P-values. | |
locstat-set! <loc> <value> | sets P-value for a locus. | |
locnotes <loc> | returns notes for a locus. | |
locnotes-set! <loc> <str> | rewrites notes for a locus. | |
loctyp <loc> | evaluates type of a locus ("adhmqx") | . |
locrank <loc> | returns rank of locus test statistic. | |
map-position <loc> | returns map position for locus. | |
map-position-set! <loc> <pos> | sets map position for locus. | |
chromosome <loc> | returns locus chromosome. | |
chromosome-set! <loc> <chr> | sets locus chromosome. | |
stat-result ["pval|lik|npars|lrt|df|stat|var"] | returns result of last model. |
Sib-pair phenotype dataset accessors:
nobs | number of pedigree records. |
npeds | number of pedigrees. |
nactpeds | number of active pedigrees |
active-status | activity status of pedigrees |
set-active-status! <idx> <lev> | set activity status of pedigree |
active-pedigrees [<idx>...] | list of active pedigree names |
pedigrees [<idx>...] | list of pedigree names. |
pedigree-size [<idx>...] | size of ith pedigree. |
pedigree-members [<idx>...] | list of indices of pedigree members |
individual-name [<idx>...] | give ID for index. |
set-pedigree-name! "<ped>" <newname> | Set pedigree ID string . |
set-individual-name! <idx>|"<id>" |("<ped>" "<id>") <newname> | Set ID string for individual. |
individual-idx [<id>|<idx>...] | give index for ID. |
father [<idx>...] | father indices. |
mother [<idx>...] | mother indices. |
imztwin [<idx>...] | MZ twin pointer. |
sex [<idx>...] | sex value for individual(s). |
set-sex! [<idx>...] <sex> | set sex value for individual. |
data <loc> [<idx>] | phenotype for individual(s). |
set-data! <idx>|"<id>" |("<ped>" "<id>") <loc> <val> | Set phenotype for individual. |
data-counts <loc> [<loc>] | tabulation of phenotype levels. |
allele-freqs <loc> | tabulation of alleles. |
There are a number of builtin statistical functions (20100323 onwards), calling the appropriate Fortran routines.
pnorm <Z> | Gaussian upper tail probability |
qnorm <p> | Gaussian quantile for given upper tail probability |
pchisq <X2> <df> [<ncp>] | Central and non central chi-square upper tail probability |
qchisq <p> <df> | Chi-square quantile for given upper tail probability |
fp <F> <df1> <df2> | F upper tail probability |
pgamma <X> <df> | Incomplete gamma integral |
lgamma <X> | Log gamma |
dbeta <X> <shape1> <shape2> | Density of Beta distribution. |
bivnor <Z1> <Z2> <r> | Bivariate Gaussian upper tail probability |
pmvnorm <p> <dir> <cor> ['genz] | Multivariate Gaussian tail probability |
pchisqsum <X> <alpha> | Upper tail probability for distributions of quadratic forms in normal variables |
And a few statistical data manipulation routines, that follow the XLispStat equivalents:
seq <sta> <fin> [<step>] | generate integer sequence. |
sort <list> | Sort a list of numbers |
order <list> | Indices of order of numbers in list |
rank <list> | Rank of numbers in list |
quantile <list> <p> | quantile(s) of list |
sample-seq <N> <size> ['replace] | sample a sequence 1..N |
sample <list> <size> ['replace] | sample a list |
differences <list> | Lag-1 differences in list |
which <list> | Indices of non-null elements of list |
unique <list> | Indices of unique elements of list |
duplicated <list> | Indices of repeat elements of list |
intersect <list> <list> | Common elements of lists |
setdiff <list> <list> | Elements unique to first list |
union <list> <list> | Elements of both lists |
list-select <list> <idx-list> | Sublist using indices |
stats <list> | N, missing, mean, variance, min, max of list. |
filter <test> <list> | filter contents of list |
Sib-pair Scheme also now (2010-05-9) contains builtin functions to call the JAPI (java application programming interface) library (http://www.japi.de), which allows building GUIs etc. JAPI allows Fortran code to interface the Java AWT (Abstract Windowing Toolkit). The JAPI website details the commands.
j_start | Start JAPI listener |
j_quit | Stop JAPI listener |
j_frame | Create a frame |
j_panel | Create a panel |
j_borderpanel | Create a borderpanel |
j_dialog | Create a dialogue |
j_button | Create a button |
j_radiobutton | Create a radiobutton |
j_radiogroup | Create a radiogroup |
j_checkbox | Create a checkbox |
j_list | Create a list |
j_add | Add an object to a container |
j_setcolor | Set the foreground colour |
j_setcolorbg | Set the background colour |
j_setnamedcolorbg | Set the background colour |
j_getselect | Return index of selected item |
j_select | Select an item |
j_deselect | Deselect an item |
j_fileselect | A file dialog |
j_filedialog | A file dialog |
j_enable | Activate an object |
j_disable | Deactivate an object |
j_additem | Add an item to a list |
j_seperator | Draw a separator |
j_textfield | Create a textfield object |
j_textarea | Create a textarea |
j_setborderpos | Place an object using borderlayout |
j_setrows | Set number of rows eg textarea |
j_setcolumns | Set number of columns eg textarea |
j_getrows | Get number of rows eg textarea |
j_getcolumns | Get number of columns eg textarea |
j_getlength | Get length in pixels of object |
j_getselstart | Start of selected text |
j_getselend | End of selected text |
j_selecttext | Select text |
j_gettext | Get text from label or list item |
j_getseltext | Get selected text |
j_getitem | Get a list item |
j_label | Create a label |
j_getcurpos | Get current cursor position |
j_setcurpos | Set current cursor position |
j_setfont | Set font |
j_settext | Set text in object |
j_inserttext | Insert text at position in eg textarea |
j_replacetext | Replace text at position in eg textarea |
j_delete | Delete text |
j_dispose | Free resource |
j_menubar | Create a menubar |
j_menu | Create a menu |
j_menuitem | Create an item for a menu |
j_pack | Pack layout of frame or panel using layout manager |
j_show | Make object visible |
j_hide | Hide object |
j_keylistener | Listen for key stroke if object active |
j_getkeycode | Returns pressed key code |
j_getkeychar | Returns pressed key ASCII code |
j_mouselistener | Listen for mouse activation |
j_getmousebutton | Return pressed mouse button |
j_nextaction | Return next action of any object |
j_getwidth | Get width of object (pixels) |
j_getheight | Get height of object (pixels) |
j_getpos | Get position of object (X.Y) |
j_setpos | Set position of object (X,Y) |
j_setsize | Get size of object (pixels) |
j_setalign | Get layout alignment for object |
j_setborderlayout | Layout manager |
j_setgridlayout | Layout manager |
j_setflowlayout | Layout manager |
Sib-pair Scheme (2010-11-29) also contains builtin functions to call the EGGX/ProCALL graphical library ( http://www.ir.isas.jaxa.jp/~cyamauch/eggx_procall/), which allows plotting and building simple GUIs etc under X Windows.
ggetdisplayinfo | Get X display info. Returns a list containing ndepth (8,16,24 bit), nrwidth (screen width), nrheight (screen height). |
gopen | Open a window. Takes two optional arguments nxwidth (width of window in pixels) and nywidth (height of window in pixels). Returns the handle (integer window index) for the opened window. |
gclose | Close the specified window. Takes one argument, the window handle. |
gcloseall | Close all active windows. Takes no arguments. |
newcoordinate | Set up new new coordinates system |
newwindow | Change the coordinates system for a window. Takes five arguments: handle, x0, y0 (bottom left), x1, y1 (top right). |
layer | Set drawing and display layers (0-7 per window). Takes three arguments: handle, index of display layer, index of drawing layer |
copylayer | Copy one layer to another. Takes three arguments: handle, index of source layer, index of destination layer. |
gsetbgcolor | Set background colour. Takes two arguments: handle, name of colour to set to (string). |
gclr | Clear the specified window. Takes one argument: handle. |
tclr | Clear the current terminal window |
newpencolor | Change pen colour (0-14). Takes two arguments: handle, number (0-14) or colour name (black, white, red, green, blue cyan, magenta, yellow, dimgray, gray, darkred, darkgreen, darkblue, darkcyan, darkmagenta, darkyellow). |
newcolor | Specify a new colour (X name). Takes two arguments: handle, name of colour to set to (string). |
newrgbcolor | Specify a new colour (RGB values). Takes four arguments: handle, R, G, B. |
newlinewidth | Specify line width. Takes two arguments: handle, line width. |
newlinestyle | Specify line style. Takes two arguments: handle, line style (0=solid, 1=dotted). |
pset | Draw a point. Takes three arguments: handle, xcoordinate, ycoordinate. |
drawline | Draw a line. Takes five arguments: handle, x0, y0, x1, y1. |
moveto | Move pen to point. Takes three arguments: handle, xcoordinate, ycoordinate. |
lineto | Draw line from current pen location to point Takes three arguments: handle, xcoordinate, ycoordinate. |
drawrect | Draw a rectangle. Takes five arguments: handle, x, y, width, height. |
fillrect | Fill a rectangle. Takes five arguments: handle, x, y, width, height. |
drawcirc | Draw a circle (ellipse). Takes five arguments: handle, x, y, xradius, yradius. |
fillcirc | Fill a circle Takes five arguments: handle, x, y, xradius, yradius. |
drawsym | Draw a symbol Takes three to five arguments: handle, x, y, optional type (1-10), optional size. |
drawstr | Print a string on the window at specified position Takes four to five arguments: handle, x, y, string, optional size. |
drawnum | Print a number on the window at specified position Takes four to six arguments: handle, x, y, string, optional size, optional number of digits. |
gsetnonblock | Set event handling to be nonblocking |
ggetch | Get a character from the keyboard if focus on window |
ggetevent | Get a keyboard or mouse event for window |
ggetxpress | Get a keyboard or mouse event for window |
Example:
>> eval %% (define (interval-list m n) (if (> m n) '() (cons m (interval-list (+ 1 m) n)))) (define (sieve l) (define (remove-multiples n l) (if (null? l) '() (if (= (modulo (car l) n) 0) ; division test (remove-multiples n (cdr l)) (cons (car l) (remove-multiples n (cdr l)))))) (if (null? l) '() (cons (car l) (sieve (remove-multiples (car l) (cdr l)))))) (define (primes<= n) (sieve (interval-list 2 n))) %% (primes<= 300) (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293) %% (quit) Leaving scheme! >> eval (primes<= 30) (2 3 5 7 11 13 17 19 23 29) >> eval (define a "hello") a >> echo %a hello >> eval (define a '(10 9 8)) a >> echo %a[2] 9
<< (let) | Up to index | >> (loop) |