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] =>
|
||||
if let some width := width.toNat?
|
||||
then do
|
||||
let mut text := ""
|
||||
let stdin ← IO.getStdin
|
||||
let mut remainder : Array String := #[]
|
||||
while true do
|
||||
let line ← stdin.getLine
|
||||
if line.isEmpty then break
|
||||
text := text ++ line
|
||||
IO.println $ solve width text
|
||||
let lines := breakUp width (remainder ++ line.words)
|
||||
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
|
||||
else fail
|
||||
| _ => fail
|
||||
|
|
Loading…
Reference in a new issue