fork download
  1. USING: io kernel math math.parser formatting sequences prettyprint io.streams.byte-array io.streams.sequence ;
  2.  
  3. IN: template
  4.  
  5. : sum-it ( n -- answer )
  6. dup 0 = ! if
  7. [ ] ! zero in stack
  8. [ 1 - ! decrease count by one
  9. readln string>number ! read next a_i
  10. swap ! a_i (n - 1) in stack
  11. sum-it + ! recur
  12. ]
  13. if ;
  14.  
  15. readln string>number
  16. sum-it ! sum n numbers from input
  17. 42 =
  18. [ "YES" print ]
  19. [ "NO" print ]
  20. if
Runtime error #stdin #stdout 1.31s 165056KB
stdin
Standard input is empty
stdout
No suitable arithmetic method
left    f
right   1
generic -