|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.cm.frw.core.fun.impl.FP
public class FP
Implementation of the FP system described in section 11 of "Can Programming be liberated from the Von Neumann Style" http://www.stanford.edu/class/cs242/readings/backus.pdf Definitions for functions and functional forms are quoted from there using the papers notation as far as possible ... Conventions:
Field Summary | |
---|---|
static Function |
add
|
static Function |
alpha
Apply to all elements of a sequence. |
static Function |
and
|
static Function |
apndl
Append left |
static Function |
apndr
Append left |
static Function |
atom
atom tests if the given argument is an atom
(i.e. |
static Function |
bu
Binary to unary |
static Function |
compose
Returns the composition of functions f and g: |
static Function |
cond
conditional function application |
static Function |
constant
Returns a constant function with given value: |
static Function |
construct
Combines functions in given collection into a function producing a sequence of results f_i(x). |
static Function |
distl
Distribute left |
static Function |
distr
Distribute right |
static Function |
divide
|
static Function |
eq
Equals: |
static Function |
id
Identity: |
static Function |
insert
Insert a binary function into a sequence. |
static Function |
length
Length |
static Function |
multiply
|
static Function |
not
|
static Function |
nul
Null: function to test if a given object is the empty sequence |
static Function |
or
|
static Function |
reverse
Reverse |
static Function |
rotl
|
static Function |
rotr
|
static Function |
rsel
rsel creates a numeric selector function (counting from one) |
static Function |
rtail
rtail produces the tail of a sequence x , i.e. |
static Function |
sel
sel creates a numeric selector function (counting from one) |
static Function |
substract
|
static Function |
tail
tail produces the tail of a sequence x , i.e. |
static Function |
transpose
|
static Function |
whyle
Build a while loop from a given predicate p
and a function f : |
Constructor Summary | |
---|---|
FP()
|
Method Summary | |
---|---|
static boolean |
atom(java.lang.Object x)
Method to simplify the use of atom |
static Function |
compose(Function f,
Function g)
|
static boolean |
equals(java.lang.Object y,
java.lang.Object z)
Method to simplify the use of eq |
static boolean |
nul(java.lang.Object x)
Method to simplify the use of nul |
static Function |
rsel(int s)
Method to simplify using rsel |
static java.util.Collection |
rtail(java.lang.Object x)
Method to simplify using rtail |
static Function |
sel(int s)
Method to simplify using sel |
static java.util.Collection |
tail(java.lang.Object x)
Method to simplify using tail |
static Function |
whyle(Predicate p,
Function f)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Function sel
sel
creates a numeric selector function (counting from one)
For any positive integer s the function created is:
(sel:s):x = x == <x1, ..., xn> && n >= s --> xs ; null
public static final Function rsel
rsel
creates a numeric selector function (counting from one)
For any positive integer s the function created is:
(sel:s):x = x == <x1, ..., xn> && n >= s --> xn-s ; null
public static final Function tail
tail
produces the tail of a sequence x
, i.e. the
sequence x
without its first element:
tail:x = x == <x1> --> <>; x == <x1 ... xn> & n >= 2 --> <x2 ... xn>; null
public static final Function rtail
rtail
produces the tail of a sequence x
, i.e. the
sequence x
without its last element:
rtail:x = x == <x1> --> <>; x == <x1 ... xn> & n >= 2 --> <x1 ... xn-1>; null
public static final Function id
id x = x
public static final Function atom
atom
tests if the given argument is an atom
(i.e. not a sequence)
atom:x = x == <x1 ... xn> --> F; x == <> --> F; x == null --> null; // bottom preserving T
public static final Function eq
eq:x = x == <y,z> && y == z --> T; x == <y,z> && y != z --> F; null
public static final Function nul
Def nul : x = x == <> --> T; x != null --> F; null
public static final Function reverse
reverse:x = x == <> --> <> x == <x1 .. xn> --> <xn ... x1> null
public static final Function distl
distl:x = x == <y, <>> --> <> x == <y, <x1 .. xn>> --> <<y,x1> .. <y,xn>> null
public static final Function distr
distl:x = x == <<>, z> --> <> x == <<x1 .. xn>, z> --> <<x1,z> .. <xn,z>> null
public static final Function length
length:x = x == <x1 ... xn> -->n x == <> --> 0 null
public static final Function add
public static final Function substract
public static final Function multiply
public static final Function divide
public static final Function and
public static final Function or
public static final Function not
public static final Function rotl
public static final Function rotr
public static final Function constant
const(x):y = y == null --> null; otherwise --> x
public static final Function compose
(f.g):x = f : ( g : x )
public static final Function construct
[f1 ... fn]:x = <f1 :x ... fn:x>
public static final Function cond
(p --> f, g):x = (p:x) --> f:x; !(p:x) --> g:x; null
public static final Function insert
/f:x = x == <x1> --> x1; x == <x1 .. xn> & n>=2 --> f:< x1, /f<x2 .. xn> >; null
public static final Function alpha
alpha f:x = x == <> --> <>; x == <x1 .. xn> --> x == <f:x1 .. f:xn> null
public static final Function transpose
public static final Function apndl
appendl:x = x == <y, <>> --> <y> x == <y, <x1 .. xn>> --> <y, x1 ... xn> null
public static final Function apndr
appendl:x = x == <<>, z> --> <z> x == <<x1 .. xn>, z> --> <x1 ... xn, z> null
public static final Function bu
(bu f x):x = f:<x, y>
public static final Function whyle
p
and a function f
:
(while p f):x = p:x == T --> (while p f):(f:x); p:x == F --> x; nullNote:Cannot have the name while in JAVA ; while the definition is recursive the implementation uses a while loop to avoid stack build up.
Constructor Detail |
---|
public FP()
Method Detail |
---|
public static Function sel(int s) throws Function.InvalidArguments
s
- a positive integer (> 0)
Function.InvalidArguments
public static Function rsel(int s) throws Function.InvalidArguments
s
- a positive integer (> 0)
Function.InvalidArguments
public static java.util.Collection tail(java.lang.Object x) throws Function.InvalidArguments
x
- an object
null
Function.InvalidArguments
public static java.util.Collection rtail(java.lang.Object x) throws Function.InvalidArguments
x
- an object
null
Function.InvalidArguments
public static boolean atom(java.lang.Object x) throws Function.InvalidArguments
atom
x
- object to test
Function.InvalidArguments
public static boolean equals(java.lang.Object y, java.lang.Object z) throws Function.InvalidArguments
eq
y
- object to test for equality with zz
- object to test for equality with y
true
, if y == z, false
otherwise
Function.InvalidArguments
public static boolean nul(java.lang.Object x) throws Function.InvalidArguments
nul
x
- object to test
true
, if x is an empty sequence, false
otherwise
Function.InvalidArguments
public static Function compose(Function f, Function g) throws Function.InvalidArguments
Function.InvalidArguments
public static Function whyle(Predicate p, Function f) throws Function.InvalidArguments
Function.InvalidArguments
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |