Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Pascals-triangle/Oz/pascals-triangle.oz
Normal file
31
Task/Pascals-triangle/Oz/pascals-triangle.oz
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
declare
|
||||
fun {NextLine Xs}
|
||||
{List.zip 0|Xs {Append Xs [0]}
|
||||
fun {$ Left Right}
|
||||
Left + Right
|
||||
end}
|
||||
end
|
||||
|
||||
fun {Triangle N}
|
||||
{List.take {Iterate [1] NextLine} N}
|
||||
end
|
||||
|
||||
fun lazy {Iterate I F}
|
||||
I|{Iterate {F I} F}
|
||||
end
|
||||
|
||||
%% Only works nicely for N =< 5.
|
||||
proc {PrintTriangle T}
|
||||
N = {Length T}
|
||||
in
|
||||
for
|
||||
Line in T
|
||||
Indent in N-1..0;~1
|
||||
do
|
||||
for _ in 1..Indent do {System.printInfo " "} end
|
||||
for L in Line do {System.printInfo L#" "} end
|
||||
{System.printInfo "\n"}
|
||||
end
|
||||
end
|
||||
in
|
||||
{PrintTriangle {Triangle 5}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue