4 ms·
(Novice k user) Exercise: Download to a single html page using k3 and curl cat 1.k c:"curl http://jsoftware.com/papers/50/"; f:("intro";"50_";"chrono";
by textmode 8y ago
(Novice k user)
Exercise: Download to a single html page using k3 and curl
cat 1.k
c:"curl http://jsoftware.com/papers/50/";
f:("intro";"50_";"chrono";"pers";"fine";"ref";"ack")
e:".htm;sleep 3"
a:{,/$(c,:[x=0;f[1],f[0];f[1]],:[x>49;f[x-48]],:[x<10;:[x=0;;0,x];:[x>49;;x]],e)}'!55
{`4:a[x]}'!55
k 1 > 1.html
firefox file:///1.html
- RodgerTheGreat 8y agoA few simplifications: c:"curl http://jsoftware.com/papers/50/50_" e:".htm;sleep 3" f:{("intro";"chrono";"pers";"fine";"ref";"ack";-2#"0",$x)0 50 51 52 53 54?x} {`4:c,f[x],e}'!55 The pattern of using find and indexing into a table with a default case is a nice way to get rid of lots of twisty conditionals.