awesome:~ apple$ cat count.sh
#!/bin/bash
count=1
LIMIT=1000001
while [ "$count" != "$LIMIT" ]
do
echo $count
let "count += 1"
done
echo "ZOMG THAT WAS AMAZING!!!1"
exit 0
#!/bin/sh /usr/bin/jot 1000000 echo "ZOMG THAT WAS so not amazing. Eleventy."And for whatever record there may be....
$ time jot 1000000 <SNIP a million numbers> real 1m0.89s user 0m5.44s sys 0m7.58sIt goes faster if you dump stdout to /dev/null, but that's hardly counting, is it?
For x = 1 to 1000000
print x
next x
for i in `jot 1000000` ; do number $1 ; echo; doneNow, it's homework time!
puts *1..10**6however, my results were problematic:
irb(main):055:0> puts *1..10**61234SystemStackError: stack level too deep from (irb):5:in `puts' from (irb):5irb(main):056:0>As it turns out, I was calling puts with a million parameters (e.g. puts(1,2,3,[snip],1000000)). I did some binary chopping and it turns out the maximum number of parameters you can put in a ruby method (at least on my system) is 644,205.
puts [*1..10**6]worked quite nicely. As trivial as this may be, I believe it to be infinitely more interesting than some twat counting to a million.
« Older Turns out that Golden Globe-winning actress Natali... | Everyone knows about Fabio, bu... Newer »
This thread has been archived and is closed to new comments
posted by dersins at 5:42 PM on June 19, 2007