Ok: * Program 2 is done, but you are supposed to use line-oriented I/O. * Raul's program was hard for me to understand, so I rewrote it in small pieces with help from Martin Neitzel. * I would appreciate a modification of my program that uses line-oriented I/O. If not, I will be forced to submit Raul's program because no one will know that it doesnt :)
#!jconsole NB. ---------------------------------------------------------------------- NB. The Computer Language Shootout NB. http://shootout.alioth.debian.org/ NB. NB. sum-file benchmark NB. http://shootout.alioth.debian.org/debian/benchmark.php?test=sumcol&lang=all NB. Authored by Raul Miller NB. Substantial help from Martin Neitzel NB. Reworked to simplified form by Terrence Brannon NB. ---------------------------------------------------------------------- file =: 1 (!:1) 3 NB. slurp file indices_with_cr =: I.file e.CRLF NB. create a list of places in string NB. where there are CRLF chararray =: ' ' indices_with_cr } file NB. replace CRLF with space numarray =: 0". chararray NB. convert charray to numarray sum =. +/ numarray echo sum exit 0 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
