Sib-pair Command: eval


ClassGlobal
Nameeval
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
absAbsolute value
andLogical and
appendAppend to end of list
applyApply function to list
aproposList matching functions
assocFind matching pair in an "alist" (list of paired values) using equal?
assqFind matching pair in an "alist" using eq?
assvFind matching pair in an "alist" using eqv?
atom?Is a simple number or string?
beginStart a block
boolean?Is a boolean?
carFirst element of pair or list
cdrRemainder of pair or list
caarFirst element of first element of pair or list
cadrUnd so weiter
cdar
cddr
caaar
cdddr
caadr
cadar
caddr
cdaar
cdadr
cddar
call/cc
call-with-current-continuation
caseConditional 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->integerReturn ASCII code
char-downcaseReturn lower case
char-upcaseReturn upper case
closure?Is a closure
condConditional branching
consCreate a Lisp pair of elements
cons-stream
current-secondReturn seconds since epoch
defineDefine a variable or function
delay
displayPrint a variable or function
doLooping construct
else
eq?
equal?
eqv?
errorPrint an error message
evalEvaluate a SEXPR (Scheme expression)
even?Test if even
exact->inexactCast to real
exitExit Sib-pair completely
exptInteger exponentiation
force
for-eachLike map, but used for side-effects only
formatPrint formatted data
gcForce a garbage collection
gcdGreatest common divisor
gensymCreate a new unique symbol
get-closure-code
helpMinimal information about Scheme
ifConditional branching
inexact->exactCast to integer
integer?Is an integer
integer->charReturn character for given ASCII code
lambdaFunction
lcmLeast common multiple
lengthGives length of a list
letDeclare a local variable
let*
letrec
listCreate a list
list?Test if a list?
list-refGives Nth element of a list
list-tailDrops the first k elements of a list
lsList Sib-pair variables
macro
make-listCreate a list of given length
make-stringCreate a string of given length
mapApply a function to each element of a list in turn
maxMaximum of arguments
memberTest if present in a list
memqTest if present in a list using equal?
memvTest if present in a list using eqv?
minMinimum of arguments
moduloGive modulo
negative?Test if negative integer
newlinePrint a newline
new-segment
notLogical negation
null?Test if a null
number?Test if an integer number
number->stringConvert from number to string
odd?Test if odd
orLogical or
pair?Test if a Lisp pair
positive?Test if a positive integer
print-width
procedure?Is a function?
quasiquoteAllow some of quoted expression to evaluate
quitLeave the Scheme interpreter
quoteQuoted expression left unevaluated
quotientInteger division
randomA random integer from U(1, N)
read
read-lineRead one line of input from standard input or file
remainderRemainder
reverseReverse ordering of a list
runRun 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
sqrtInteger 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-appendConcatenate strings
string-lengthLength of argument string
string-refGet kth character from string
string-set!Set the value of a substring
string-splitSplit a string into a list of words
string->numberConvert from a string to a number
string->symbolConvert from a string to a symbol
substringGet the value of a substring
symbol?Is a symbol?
symbol->stringConvert from a symbol to a string
systemPasses 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.
helpInformation 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_startStart JAPI listener
j_quitStop JAPI listener
j_frameCreate a frame
j_panelCreate a panel
j_borderpanelCreate a borderpanel
j_dialogCreate a dialogue
j_buttonCreate a button
j_radiobuttonCreate a radiobutton
j_radiogroupCreate a radiogroup
j_checkboxCreate a checkbox
j_listCreate a list
j_addAdd an object to a container
j_setcolorSet the foreground colour
j_setcolorbgSet the background colour
j_setnamedcolorbgSet the background colour
j_getselectReturn index of selected item
j_selectSelect an item
j_deselectDeselect an item
j_fileselectA file dialog
j_filedialogA file dialog
j_enableActivate an object
j_disableDeactivate an object
j_additemAdd an item to a list
j_seperatorDraw a separator
j_textfieldCreate a textfield object
j_textareaCreate a textarea
j_setborderposPlace an object using borderlayout
j_setrowsSet number of rows eg textarea
j_setcolumnsSet number of columns eg textarea
j_getrowsGet number of rows eg textarea
j_getcolumnsGet number of columns eg textarea
j_getlengthGet length in pixels of object
j_getselstartStart of selected text
j_getselendEnd of selected text
j_selecttextSelect text
j_gettextGet text from label or list item
j_getseltextGet selected text
j_getitemGet a list item
j_labelCreate a label
j_getcurposGet current cursor position
j_setcurposSet current cursor position
j_setfontSet font
j_settextSet text in object
j_inserttextInsert text at position in eg textarea
j_replacetextReplace text at position in eg textarea
j_deleteDelete text
j_disposeFree resource
j_menubarCreate a menubar
j_menuCreate a menu
j_menuitemCreate an item for a menu
j_packPack layout of frame or panel using layout manager
j_showMake object visible
j_hideHide object
j_keylistenerListen for key stroke if object active
j_getkeycodeReturns pressed key code
j_getkeycharReturns pressed key ASCII code
j_mouselistenerListen for mouse activation
j_getmousebuttonReturn pressed mouse button
j_nextactionReturn next action of any object
j_getwidthGet width of object (pixels)
j_getheightGet height of object (pixels)
j_getposGet position of object (X.Y)
j_setposSet position of object (X,Y)
j_setsizeGet size of object (pixels)
j_setalignGet layout alignment for object
j_setborderlayoutLayout manager
j_setgridlayoutLayout manager
j_setflowlayoutLayout 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.

ggetdisplayinfoGet 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)