Ok, this is so offtopic that is nearly embarassing, but here goes.
I found on the net the attached picture (quite amazing in itself), so I
thought it'd be nice to write a hansl script to reproduce it. It turns
out the the little script below showcases quite a few features hansl has
(eg recursion, logical operators etc), so it could maybe be useful to
people who are teaching/learning Hansl. Enjoy!
<hansl>
set verbose off
function matrix prime_sieve(scalar n)
x = floor(sqrt(n))
c = seq(2,n)
prime = ones(1,n-1)
loop i = 2 .. x --quiet
prime[i+1:] = prime[i+1:] && !(c[i+1:] % i .= 0)
endloop
return selifc(c, prime)
end function
function scalar droot(scalar x)
y = floor(x)
ret = 0
loop while y >= 1 --quiet
ret += y % 10
y = floor(y/10)
endloop
if ret > 9
ret = droot(ret)
endif
return ret
end function
x = prime_sieve(200)
loop i = 1 .. nelem(x) --quiet
c = x[i]^3
printf "%5d: %5d\n", x[i], droot(c)
endloop
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------