RosettaCodeData/Task/Floyds-triangle/Refal/floyds-triangle.refal

50 lines
1.0 KiB
Plaintext

$ENTRY Go {
= <Prout <Floyd 5>>
<Prout <Floyd 14>>;
};
Floyd {
s.N, <Rows s.N>: e.Rows,
e.Rows: e.X (e.MaxRow),
<Each Width e.MaxRow>: e.ColWidths =
<Each ((e.ColWidths)) FormatRow e.Rows>;
}
FormatRow {
(e.W) () = '\n';
(s.W e.WS) (s.C e.CS) = <Cell <+ 1 s.W> s.C> <FormatRow (e.WS) (e.CS)>;
};
Cell {
s.Width s.N, <Repeat s.Width ' '> <Symb s.N>: e.Rfill,
<Last s.Width e.Rfill>: (e.X) e.Cell = e.Cell;
}
Rows {
s.Rows = <Rows s.Rows 1 1>;
s.Rows s.Row s.N, <+ s.Rows 1>: s.Row = ;
s.Rows s.Row s.N, <+ s.N s.Row>: s.Next =
(<Row s.N <- s.Next 1>>)
<Rows s.Rows <+ s.Row 1> s.Next>;
}
Row {
s.To s.To = s.To;
s.From s.To = s.From <Row <+ s.From 1> s.To>;
};
Each {
s.F e.X = <Each () s.F e.X>;
(e.Arg) s.F = ;
(e.Arg) s.F t.I e.X = <Mu s.F e.Arg t.I> <Each (e.Arg) s.F e.X>;
};
Width {
s.N, <Symb s.N>: e.X, <Lenw e.X>: s.Width e.X = s.Width;
};
Repeat {
0 s.X = ;
s.N s.X = s.X <Repeat <- s.N 1> s.X>;
};