One thing I'd like to improve is,
The duplication that would occur between hdef2 and hdefine2(not
implemented yet).
The original definition is,
hdefine
1 : 'm : (hrep 0 : 0)'
hdef
2 : 'm : (hrep n)'
Now that I have hdef2, how could I define hdefine2 without much duplication?
2007/5/28, June Kim <[EMAIL PROTECTED]>:
Thank you for the hint. Following is my attempt at using locales. Any
suggestions for improvement?
require 'web/jhp'
v2=: 3 : 0
(monad hdef2 y) ''
)
hdef2=: 2 : 0
'' m hdef2 n y
:
start=.coname ''
cocurrent this=. cocreate ''
r=: ''
print=: 3 : '''''[r=: r,padj y'
println=: 3 : '''''[r=: r,LF,~ padj y'
x 4 : (hrep n) y
here=. r
cocurrent start
coerase this
here
)
male=: monad hdef2 'Mr. <%= y%>'
couple=: dyad hdef2 'Mr. <%=x%> and Mrs. <%=y%>'
he=:person=: 'Joe'
she=:'Jane'
v2 'Hello, <%=male_base_ person_base_%>!'
Hello, Mr. Joe!
v2 'Hello, <%=he_base_ couple_base_ she_base_%>!'
Hello, Mr. Joe and Mrs. Jane!
2007/5/28, Raul Miller <[EMAIL PROTECTED]>:
> On 5/27/07, June Kim <[EMAIL PROTECTED]> wrote:
> > Maybe, using locales is better?
>
> I'd think so.
>
> Try putting
> cocurrent this=.cocreate''
> at the top of v, and
> coerase this
> on the second to last line.
>
> Note, however, that any "globally defined names" must be
> qualified with their locale (for example base) if they're not in z,
> if you want to reference them from jhp text which is used in
> this fashion.
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm