R.E. Boss wrote:
>
> Viktor Cerovski wrote
>>
>>
>> mapply4=: 4 : 0
>> ri=.0
>> while. ri<#x do.
>> 'p s t'=.ri{x
>> 'y ri'=.((s , (#p) }. ])&.(j&|.)@>@{. ; t*_:)^:((#y)~:j=.i.&1 p E. y)
>> y;>:ri
>> end.
>> y
>> )
>
>
> R1 mapply4 T1
> |domain error: mapply4
> | 'p s t'=.ri {x
>
> NB. for R1 and T1 see
> http://jsoftware.com/pipermail/programming/2009-December/017323.html
>
>
> R.E. Boss
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
I've used tests prepared by Thomas. Here is the copy of a session:
$ ~/j64-602/bin/jconsole
do=.".
NB. RULE=. PAT;SUB;TERMINAL
RULES1=: do;._2 ] 0 : 0
'A';'apple';0
'B';'bag';0
'S';'shop';0
'T';'the';0
'the shop';'my brother';0
'a never used';'terminating rule';1
)
TEST1=: 1 : 0
'I bought a bag of apples from my brother.' -: RULES1 u 'I bought a B of
As from T S.'
)
RULES1
+------------+----------------+-+
|A |apple |0|
+------------+----------------+-+
|B |bag |0|
+------------+----------------+-+
|S |shop |0|
+------------+----------------+-+
|T |the |0|
+------------+----------------+-+
|the shop |my brother |0|
+------------+----------------+-+
|a never used|terminating rule|1|
+------------+----------------+-+
mapply4=: 4 : 0
ri=.0
while. ri<#x do.
'p s t'=.ri{x
'y ri'=.((s , (#p) }. ])&.(j&|.)@>@{. ; t*_:)^:((#y)~:j=.i.&1 p E. y)
y;>:ri
end.
y
)
mapply4 TEST1
1
RULES1 mapply4 'I bought a B of As from T S.'
I bought a bag of apples from my brother.
--
View this message in context:
http://old.nabble.com/Tacit-exercise-tp26812445s24193p26857035.html
Sent from the J Programming mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm