n Apr 14th, 2006, I wrote: > triangle =: (1&(,~ ~:/\^:_1)&(i. 0))@:<
On Apr 16th, 2006, June Kim wrote: > What is the logic behind ~:/\^:_1 ? You know, I never responded this question because I didn't know the answer. It just seemed "obvious" to me that the ~:/\ would do the Sierpinsky thing. But the other day I received the latest issue of Vector in the mail. Reading it today I came across an article that explained the logic: http://vector.org.uk/archive/v222/lang222.htm On page 66, Camacho cites an article of Langlet's she had previously translated and submitted to Vector (http://vector.org.uk/archive/v193/). In that article, Langlet points out that ~:/\ on a vector of ones will cycle and produce the "Sierpinsky Gasket" (but he used APL notation). In J, try: sierp_gask =: ~:/\^:( < ` (] # 1:) ) NB. Monadic verb, argument is scalar non-negative integer require 'viewmat' viewmat sierp_gask 100 Using ~:/\^:_1 in place of ~:/\ produces a related structure: sierp_tri =: ~:/\^:_1^:( < ` (] # 1:) ) viewmat (sierp_gask ,. sierp_tri) 100 NB. More generally... sierp =: ~:/\^:( < ` (| # 1:) )"0 NB. Vector of integers (of any sign) viewmat ,./ sierp 1 _1 * 100 The article is a little difficult for me to follow, but I thought it was neat. -Dan PS: By the way, I don't know if you know about the adverb b. but sometimes it can be enlightening: ~:/\ b. _1 (~: |.!.0) :.(~:/\) That is, ~:/\^:_1 -: (~: |.!.0) . ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
