|syntax error: scriptd | smoutput,.'Big GFT';BIG_GFT=:8 ' 'Gft_dwl'/|\O'
|[-22] c:\users\owner\j701-user\temp\55.ijs

Here is the problem that I had at first, and I got it again as
shamrock_dwl.ijs

I had a similar message with the first script and then I entered much of it
by hand.

I had more luck when I cut out all the comments.

Linda
-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of David Ward Lambert
Sent: Sunday, March 18, 2012 1:21 PM
To: programming
Subject: Re: [Jprogramming] Shamrock solution

NB. Save message text as script  shamrock_dwl.ijs .
NB. Run on 80 width and height terminal with, roughly, NB.
-----------------------------------
NB. shell_prompt$ jconsole shamrock_dwl.ijs NB.
-----------------------------------
NB. Not bad in jgtk except that the final plot doesn't work.
NB. Works in jhs---remove the final line,  exit 0


TAU=: 2p1               NB. http://laughingsquid.com/pi-is-wrong/
range=: 1&$: : (* (%~ i.))
radian_range=: TAU&range
NB.grid_cartesian y  returns delightful boxes of Cartesian product
grid_cartesian=: 2&$: : ({@:(# <@:(%~ i:)))

NB. create_round_mask radius
NB.   returns Boolean square array, 1 within circle
NB.   result depends on comparison tolerance, 9!:18, 9!:19
create_round_mask=: (1-1e_14) >: |@:j./@>@:grid_cartesian

NB. 1j1&#&.|: is slow and fat, that is to say, 1j1&#"1 is faster
vex=: expand_for_character_cell_display=: 1j1&#"1

NB. grapefruit tree adverb
NB. m is the background, x controls size, y are the drawing chars
Gft_dwl=: adverb define
5 m Gft_dwl y
:
TOP_VIEW_TREE=.((create_round_mask x)})(m&,:)y{~(2#>:+:x)?@:$(#y) vex
TOP_VIEW_TREE
)

smoutput ,.'Big GFT';BIG_GFT=: 8' 'Gft_dwl'/|\O'

LEMON_TREE_AT_NIGHT=: 5'.'Gft_dwl'/|\o'
smoutput ,.'Moonlit lemon tree';LEMON_TREE_AT_NIGHT

NB. ASCII humor.  Thank you.
PARCHED_STAR_FRUIT=:  5''Gft_dwl'*',3#'/|\'
smoutput ,.'Underbearing carambola';PARCHED_STAR_FRUIT

NB. new approach for the shamrock.
NB. 2 trifolium curves with offset rotation NB. form the leaf lobes.
NB. Draw these curves at various radial scales NB. to fill the leaves.

NB. trifolium, dyad.
NB. x controls the rotation, x defaults to no rotation.
NB. y are the angles in radians at which NB. to evaluate the trifolium
curve.
trifolium=: 0&$: : (4 : 0)
ROTATION=: 3 * x
PHI=. y
R=. ROTATION (1 o. ] p.~ 3 ,~ [) PHI
R *"1 (2 1 o./PHI)
)

NB. dyad create_shamrock_mask
NB. x controls the leaf lobe separation
NB. y is roughly the radius of the bounding circle NB. Algorithm:
NB.   generate indexes into a square array.
NB.     trifolium curves create shamrock outline.
NB.     Scale the radius, the multiple outlines "fill" shamrock.
NB.   Then use amend.
create_shamrock_mask=: 0&$: : (4 : 0)"0
GRID=. i:1 j. y
NB. An adjective would help to free these density parameters
RADIAL_DENSITY=. 8 OUTLINE_DENSITY=. 555 NB. The hook constructs shamrock
polar curve T=. x (trifolium radian_range) OUTLINE_DENSITY NB. construct
non-linear grid of radius factors NB. square root makes the bigger factors
closer.
NB. The hook merely substitutes a 1 for the 0 FR=. %:@:(+ 0&=)@:range
RADIAL_DENSITY INDEXES=. ~. <"1 ,/ |: GRID I. T*/FR
1 INDEXES } 0 $~ 2 # >: y
)

NB. in following sentence 37 is roughly the half width NB. of the final
shamrock, and 0.2 controls leaf lobe separation.
SHAMROCK=: ' X'{~+./ (1 _1*0.2) create_shamrock_mask 37 smoutput ,.'St.
Pat';vex SHAMROCK

smoutput'If you replace the threes in trifolium with fours'
smoutput'  does the code draw a lucky clover?'
smoutput'See comments about global comparison tolerance.'

load'plot'
plot ;/ trifolium radian_range 100

NB. exit 0


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to