13.07.2015 Views

Getting started with Imalab and Scheme - PRIMA

Getting started with Imalab and Scheme - PRIMA

Getting started with Imalab and Scheme - PRIMA

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

(quit) ends imalab. This is equivalent to ctrl-d.Interrupt execution: type ctrl-c. If this does not get you back to the shell, type ctrl-c twice again.2.3 <strong>Imalab</strong> screenInteraction <strong>with</strong> the imalab screen are possible in continuous mode, not in interactive mode. To switch to continuousmode type (continue). For screen interaction, place the mouse cursor <strong>with</strong>in the imalab screen window. Use thekeyboard to type comm<strong>and</strong>s.q quits continuous mode, goes to interactive mode. Typing (continue) in the shell brings you back to continuousmode.space switches between step mode <strong>and</strong> movie mode. The current-image <strong>and</strong> the following images are displayed.arrow up displays frame(t-10) (in step mode). The image cache is by default set to 60 images.arrow down displays frame(t+10) (in step mode)arrow right displays frame(t+1) (in step mode)arrow left displays frame(t-1) (in step mode)mouse click displays circle in all windows (in step mode)3 Basic <strong>Scheme</strong>A scheme expression can either be a variable or a procedure call.variablename displays the value stored in the location to which the variable is bound.A scheme comm<strong>and</strong> is structured as follows: opening parenthesis, function name followed by 0 or several parameters,closing parenthesis. This is true <strong>with</strong>out exception; in particular, arithmetic operators are just functions. Examples:(function no params)(function <strong>with</strong> 1 parameter param1)(function <strong>with</strong> 2 parameters param1 param2)Parameters can be anything, numbers, variable names, functions, ... . Typical examples are:(list) function <strong>with</strong> no parameters, creates an empty list(sin 1.0) function <strong>with</strong> 1 numerical parameter, computes the sine of 1.0(* 2 5) function <strong>with</strong> 2 numerical parameters, computes product of 2 <strong>and</strong> 5(define a 0.0) function <strong>with</strong> 2 parameters, assigns the value 0.0 to a variable named a(+ 1 4.0 3.2) function <strong>with</strong> 3 (or more parameters), computes the sum of the parameters.<strong>Scheme</strong> functions always give a value, which may be of any type: in cases of numerical calculations this is the result.In other cases, the return value can be an object (i.e. an image, a list) or a boolean (#t notes true, <strong>and</strong> #f notes false).The return value of a function can be assigned to a new variable as follows:(define empty list (list)) initialises a variable <strong>with</strong> name empty list <strong>and</strong> assigns the return value of(list) to it.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!