A+B: Difference between revisions
Content added Content deleted
(→{{header|Tcl}}: Added a one-liner; less clear IMO but still neat) |
(→{{header|Tcl}}: Do it with files!) |
||
Line 212: | Line 212: | ||
Alternatively: |
Alternatively: |
||
<lang tcl>puts [tcl::mathop::+ {*}[gets stdin]]</lang> |
<lang tcl>puts [tcl::mathop::+ {*}[gets stdin]]</lang> |
||
To/from a file: |
|||
<lang tcl>set in [open "input.txt"] |
|||
set out [open "output.txt" w] |
|||
scan [gets $in] "%d %d" x y |
|||
puts $out [expr {$x + $y}] |
|||
close $in |
|||
close $out</lang> |