3 ms·
Ask HN: Who enjoyed the 10 Print book?
I'm really enjoying the 10 PRINT book from a previous post.
http://10print.org/
I thought about implementing it in the languages I use currently and it's much more verbose. I mainly use Python, Java and PL/SQL. I'm sure some people here can do better!
Python:
import random,sys
while 1 : sys.stdout.write( "/" if int(random.random()+0.5) else "\\")
PL/SQL - not really one line but possible - first time I've used PUT rather than PUT_LINE:
declare i number; begin for i in 1..10000 loop if round(dbms_random.value)=0 then dbms_output.put('/'); else dbms_output.put('\'); end if; end loop; dbms_output.new_line; end;
Haven't done java yet!
Lets see some variations in the languages you usually use.
- thorin 13y agoPS shame it is so hard to poke to memory these days without using C/assembly.