streaming
This commit is contained in:
parent
0706170d95
commit
f03131610f
1 changed files with 7 additions and 3 deletions
10
Main.lean
10
Main.lean
|
@ -59,13 +59,17 @@ def main : List String → IO UInt32
|
||||||
| [width] =>
|
| [width] =>
|
||||||
if let some width := width.toNat?
|
if let some width := width.toNat?
|
||||||
then do
|
then do
|
||||||
let mut text := ""
|
|
||||||
let stdin ← IO.getStdin
|
let stdin ← IO.getStdin
|
||||||
|
let mut remainder : Array String := #[]
|
||||||
while true do
|
while true do
|
||||||
let line ← stdin.getLine
|
let line ← stdin.getLine
|
||||||
if line.isEmpty then break
|
if line.isEmpty then break
|
||||||
text := text ++ line
|
let lines := breakUp width (remainder ++ line.words)
|
||||||
IO.println $ solve width text
|
if h : lines.size > 0 then
|
||||||
|
remainder := lines[lines.size-1]
|
||||||
|
for line in lines[0:lines.size-1] do
|
||||||
|
IO.println $ justify width line
|
||||||
|
IO.println $ String.intercalate " " remainder.toList
|
||||||
return 0
|
return 0
|
||||||
else fail
|
else fail
|
||||||
| _ => fail
|
| _ => fail
|
||||||
|
|
Loading…
Reference in a new issue