# Sib-pair Command: eval

 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 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 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 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 lists commands containing that string. help Information about this Scheme implementation. isatty? test if interactive session. file-exists? test file. file-list [] list files in directory (Posix). file-delete delete file. open-input-file open a port. close-input-port close a port. read-line [] reads in next line from stdin or open file. format "{~[:num:][@][ASD~%]}" ... formatted output. regexp searches for regular expression in string. string-split [] splits string on white space or optional char. substring? returns start of substring in string. system passes command to shell. getenv returns value of environment variable. date returns current date and time. time returns current time as number of seconds since epoch. environment-bound? test if symbol bound to a variable

 version prints Sib-pair version. run ... runs a Sib-pair command. pass-command ... stores Sib-pair commands to the buffer for evaluation once you return to the usual Sib-pair prompt.

Sib-pair locus dataset accessors:

 ls [] creates a list of locus names (of given type "adhmqx" . nloci returns total number of loci. loc returns locus at that position in the locus list. loc-set! set name of locus at that position in the locus list. locord returns position of a locus in the locus list. locstat returns last P-value for a locus. locstat-init! 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! set activity status of pedigree active-pedigrees [...] list of active pedigree names pedigrees [...] list of pedigree names. pedigree-size [...] size of ith pedigree. pedigree-members [...] list of indices of pedigree members individual-name [...] give ID for index. set-pedigree-name! "" Set pedigree ID string . set-individual-name! |"" |("" "") Set ID string for individual. individual-idx [|...] give index for ID. father [...] father indices. mother [...] mother indices. imztwin [...] MZ twin pointer. sex [...] sex value for individual(s). set-sex! [...] set sex value for individual. data [] phenotype for individual(s). set-data! |"" |("" "") Set phenotype for individual. data-counts [] tabulation of phenotype levels. allele-freqs tabulation of alleles.

There are a number of builtin statistical functions (20100323 onwards), calling the appropriate Fortran routines.

 pnorm Gaussian upper tail probability qnorm

Gaussian quantile for given upper tail probability pchisq [] Central and non central chi-square upper tail probability qchisq

Chi-square quantile for given upper tail probability fp F upper tail probability pgamma Incomplete gamma integral lgamma Log gamma dbeta Density of Beta distribution. bivnor Bivariate Gaussian upper tail probability pmvnorm

['genz] Multivariate Gaussian tail probability pchisqsum Upper tail probability for distributions of quadratic forms in normal variables

And a few statistical data manipulation routines, that follow the XLispStat equivalents:

 seq [] generate integer sequence. sort Sort a list of numbers order Indices of order of numbers in list rank Rank of numbers in list quantile

quantile(s) of list sample-seq ['replace] sample a sequence 1..N sample ['replace] sample a list differences Lag-1 differences in list which Indices of non-null elements of list unique Indices of unique elements of list duplicated Indices of repeat elements of list intersect Common elements of lists setdiff Elements unique to first list union Elements of both lists list-select Sublist using indices stats N, missing, mean, variance, min, max of list. filter 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.

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)