File size: 983 Bytes
557a17a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Mode Statements

* In the following,

test_types_cases(2,`[[n,function],[[v,a],[v,b],[v,c]]]`,
`[[[n,function],[[t,number],[t,string],[t,predicatename]]]]`,
`[[[n,function],[output,output,output]]]`,
[
`[[n,function],[[v,a],[v,b],[v,c]],":-",[[[n,=],[[v,a],1]],[[n,=],[[v,b],"a"]],[[n,=],[[v,c],[n,a]]]]]`
],
`[[[[v,a], 1],[[v,b], "a"],[[v,c], [n,a]]]]`).

* `[[[n,function],[output,output,output]]]`, is the mode statement, which must follow the type statement (although these are optional). The Mode Statement specifies whether each of the variables takes input or gives output.

# Functional List Prolog (FLP)

* List Prolog has an optional functional mode.  In FLP, function calls may be passed as variables and functions may have strong types.

* Functional algorithms may be recursive (see test 7 in <a href="https://github.com/luciangreen/listprologinterpreter/blob/master/lpiverify4_types.pl">lpiverify4_types.pl</a>), i.e. they may repeat until triggering the base case: