phil_algs / Languages /docs9.txt
luciangreen's picture
Upload 1424 files
557a17a verified
# 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: