A+B: Difference between revisions

(Added Terraform Implementation)
Line 3,105:
<lang J> 2+3
5</lang>
Next we describe then implement a command line program to add some numbers.
In the following expression, <tt>1!:1(3)</tt> reads a line from STDIN; <tt>-.LF</tt> drops the line ending character; <tt>".</tt> converts the remaining text to a sequence of numbers which are then summed using <tt>+/</tt>.
 
1) In the following expression, <tt>1!:1(3)</tt> reads a line from STDIN; <tt>-.LF</tt> drops the line ending character; <tt>".</tt> converts the remaining text to a sequence of numbers which are then summed using <tt>+/</tt>.
<lang J>+/". (1!:1(3))-.LF</lang>
2) Here's a little script, called "a+b.ijs":
<lang J>#!/Applications/j602/bin/jconsole
echo +/". (1!:1(3))-.LF
exit ''</lang>
3) Here is thean execution of the script:
<lang bash>echo 2 3 | ./a+b.ijs
5</lang>
6,962

edits