Output of file : FISCHER.LST contained in archive : DDJ1289.ZIP
_FUNCTIONAL PROGRAMMING AND FPCA'89_
by Ronald Fischer

[FIGURE 1]

DEC silly: LIST(CHAR)->LIST(LIST(CHAR));
--- silly(NIL) <= ["Thank you for using "];
--- silly(onechar::remaining) <=
(IF member(onechar,"0123456789") THEN "That's fine!\n"
ELSE "Please type only digits!\n") :: silly(remaining);

TYPEVAR any_type;
DEC member: any_type # LIST(any_type) -> TRUVAL;
--- member(_,NIL) <= FALSE;
--- member(a,a::t) <= TRUE;
--- member(a,_::t) <= member(a,t);

[FIGURE 2]

|| MIRANDA example program
|| defining a tree whose nodes can be any type
|| the type is represented by the asterisk symbol
tree * ::= niltree | node * (tree *) (tree *)

|| Now implementing a sort algorithm
|| To sort a tree, first flatten it to get a list of nodes
|| Next build a sorted tree from the list
sort = flatten . buildsorted

|| This defines how to flatten a tree
flatten niltree = [] || Flattening an empty tree gives the empty list
|| To flatten any other tree, flatten the left subtree first,
|| append the root, and append the flattened right subtree.
flatten (node a left right) = flatten left ++ [a] ++ flatten right

|| This defines how to build a sorted tree from an unsorted list
|| Note: "<=" and ">" must be defined on tree nodes!
buildsorted = foldr insert niltree || foldr is a predefined transformer!
where
insert a niltree = node a niltree niltree
insert a (node b left right)
= node b (insert a left) right, a<=b
= node b left (insert a right), a>b

[FIGURE 3]

# Defining the FACTORIAL function in NIAL
# i.e. factorial 4 results in 16

factorial IS FORK
[ 1 >= , 1 first ,
times [ pass , factorial (1 CONVERSE minus) ]
]

# Defining the AVERAGE of a list of values
# i.e. average 3 9 5 3 results in 4
average IS / [sum,tally]

[FIGURE 4]

main resps =
case resps of
(Return Val: _) ->
AppendChan "stdout" Text Val ]



### 3 Responses to “Category : Files from MagazinesArchive   : DDJ1289.ZIPFilename : FISCHER.LST”

1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/