Mercurial > hg > plml
changeset 34:439e7d337647
Merged something?
author | samer |
---|---|
date | Tue, 25 Sep 2012 09:58:10 +0100 |
parents | fc72b98aba8c (current diff) f2339ddcfe95 (diff) |
children | af5fa681278e |
files | prolog/plml.pl |
diffstat | 1 files changed, 22 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/prolog/plml.pl Tue Sep 25 09:57:24 2012 +0100 +++ b/prolog/plml.pl Tue Sep 25 09:58:10 2012 +0100 @@ -99,6 +99,8 @@ X,Y % |--> V[X], V[Y] (sequential evaluation displaying first result) X=Y % |--> V[X]=V[Y] (assignment, X must denote a valid left-value) hide(X) % |--> V[X]; (execute X but hide return value) + if(X,Y) % |--> if V[X], V[Y], end + if(X,Y,Z) % |--> if V[X], V[Y], else V[Z], end == Things that look and work like Matlab syntax (more or less): @@ -273,15 +275,21 @@ % If Host is not given, it defaults to localhost. Session will be % associated with the given Id, which should be an atom. See ml_open/3. % -% Valid options are -% * noinit -% If present, do not run initialisation commands specified by -% matlab_path/2 and matlab_init/2 clauses. Otherwise, do run them. +% Valid options are below. Note that matlab is always called with +% the -nodesktop and -nosplash options. +% * noinit +% If present, do not run initialisation commands specified by +% matlab_path/2 and matlab_init/2 clauses. Otherwise, do run them. % * debug(In,Out) % if present, Matlab is started in a script which captures standard % input and output to files In and Out respectively. (tbd) -% -% [What if session is already open and attached to Id?] +% * cmd(Cmd:atom) +% Call Cmd as the matlab executable. Default is 'matlab' (i.e. search +% for matlab on the PATH).. Can be used to select a different executable +% or to add command line options. +% * awt(Flag:bool) +% If false (default), call Matlab with -noawt option. Otherwise, Java graphics +% will be available. ml_open(Id) :- ml_open(Id,localhost,[]). ml_open(Id,Host) :- ml_open(Id,Host,[]). @@ -321,7 +329,12 @@ nofail(P) :- catch(ignore(call(P)), E, print_message(warning,E)). nofail(P,X) :- catch(ignore(call(P,X)), E, print_message(warning,E)). -options_flags(_,'-nodesktop -nosplash -noawt'). +options_flags(Opts,Flags) :- + option(awt(AWT),Opts,false), + ( AWT=true + -> Flags='-nodesktop -nosplash' + ; Flags='-nodesktop -nosplash -noawt' + ). %% ml_exec(+Id:ml_eng, +Expr:ml_expr) is det. @@ -409,6 +422,8 @@ stmt(I,(A;B)) --> !, stmt(I,A), ";", stmt(I,B). stmt(I,(A,B)) --> !, stmt(I,A), ",", stmt(I,B). stmt(I,A=B) --> !, ml_expr(I,A), "=", ml_expr(I,B). +stmt(I,if(A,B)) --> !, "if ",ml_expr(I,A), ", ", stmt(I,B), ", end". +stmt(I,if(A,B,C)) --> !, "if ",ml_expr(I,A), ", ", stmt(I,B), ", else ", stmt(I,C), ", end". stmt(I,Expr) --> !, ml_expr(I,Expr).