2Q: Stdio rationale & "systolic" array?
Matti J. Nykanen
mnykanen@cs.Helsinki.FI
Fri, 13 Feb 1998 15:34:46 +0200 (EET)
Cleanness is next to Gödelness,
I have 2 questions for you experienced Clean users.
1. Unless I am mistaken, currently console I/O is performed via a
single read-write text file. Why not separate "stdin" and "-out"?
2. I am trying to implement a kind of a "systolic array" algorithm in
Clean, which would use in situ updates instead of copies, but I cannot
get the uniqueness typing system to agree. Could someone show how the
following pseudo-Pascal algorithm is Cleaned?
PROCEDURE systolic(
VAR V:ARRAY[0..N] OF Boolean;
I:0..N)
BEGIN
FOR J:=I TO N DO
V[J]:=V[J] OR V[J-I]
END;
In other words, the datum V[J] reads the datum V[J-I] I places to its
left, performs an OR, and passes the result into the datum V[J+I] I
places to its right (if any) as well.
For example, given V={True,False,False,False,..} and I=2, the
algorithm returns V={True,False,True,False,True,False,..}, and does
this by modifying the given V.
Matti Nykänen
P.S. Regarding the recent "dinosaur" discussion, note that the small,
nimble, furry mammals did in no way *win* the dinosaurs; instead, the
dinosaurs *lost*, because their environment changed irrevocably, no
thanks to the mammals, and the dinosaurs could no longer adapt. A
"better" species does not necessarily win, if the prevailing one is
"good enough".