User defined pipe and redirection operators/ALGOL 68: Difference between revisions

m
Fixed syntax highlighting.
m (Fixed syntax highlighting.)
 
Line 3:
==Iterator_pipe_operators==
'''File: Iterator_pipe_operators.a68'''
<langsyntaxhighlight lang="algol68">MODE
PAGEIN = PAGE,
PAGEAPPEND = REF PAGE,
Line 23:
>> = (GENLINE gen, PAGEAPPEND page)VOID: gen(APPEND page),
=: = (GENLINE gen, FILTER filter)GENLINE: filter(gen),
=: = (GENLINE gen, MANYTOONE cmd)GENLINE: cmd(gen);</langsyntaxhighlight>
 
==Iterator_pipe_utilities==
'''File: Iterator_pipe_utilities.a68'''
<langsyntaxhighlight lang="algol68">PROC cat yield line = ([]GENLINE argv, YIELDLINE yield)VOID:
FOR gen line FROM LWB argv TO UPB argv DO
argv[gen line](yield)
Line 122:
 
# Define an optional monadic OPerator #
OP TAIL = (INT n)MANYTOONE: tail(n, );</langsyntaxhighlight>
==Iterator_pipe_page==
'''File: Iterator_pipe_page.a68'''
<langsyntaxhighlight lang="algol68"># Define the required OPerators for pipes of user-defined type "PAGE" #
OP +:= = (PAGEOUT page, LINE line)MOID:(
[LWB page:UPB page+1]LINE out;
Line 150:
 
OP APPEND = (PAGEAPPEND page)YIELDLINE:
page append line(page, );</langsyntaxhighlight>
 
==test_Iterator_pipe_page==
'''File: test_Iterator_pipe_page.a68'''
<langsyntaxhighlight lang="algol68">#!/usr/local/bin/a68g --script #
# First define what kind of record (aka LINE) we are piping and filtering #
FORMAT line fmt = $xg$;
Line 206:
$"Number of Algol pioneers: "g(-0)$, UPB algol pioneers list, $l$,
$"Number of scientists: "g(-0)$, UPB the scientists list, $l$
))</langsyntaxhighlight>
'''Output:'''
<pre>
9,476

edits