Re: [Jprogramming] sorting using verb returing a boolean

2023-12-21 Thread 'Pascal Jasmin' via Programming
 The same output of your quoted "program"

\:~ _10 1 10 20 _30 15 25 30 0

30 25 20 15 10 1 0 _10 _30

I may have misunderstood your original question, based on subject line.  You 
appear to want to sort card hands.
You would want to encode cards as integers, where 2-A maps to 0-13.  It is a 
good J datastructure if you wanted suits to represent it as a "handsize" by 2 
shaped table, and 3 dimensional J data would store multiple items of hands.
> 2 is greater than A> 23452 is lesser than 23453
from a lexicographical sort perspective,

(0 12 12 12 12) ([ -: {.@:(\:~)@:,:) 12 0 0 0 0
0 NB.  2 is greater than A ... is false from a descending lexographical 
sort perspective.
What it appears your desired verb to be is to assess the value/rank of poker 
hands.  The scoring function for poker hands can/is be monadic.
compareV =: (>&) NB. adverb that will compare 2 scoring functions applied to 
each dyadic argument.
pokerhandscoringfunction compareV





On Thursday, December 21, 2023 at 10:17:41 a.m. EST, 'Viktor Grigorov' via 
Programming  wrote:  
 
 Maybe a table, summation and a sort using that:

   (/: ([:+/(>/]))) _10 1 10 20 _30 15 25 30 0
Can't imagine that being efficient, but it's better than nothing. The verb I'd 
defined can't deal with rank 2 nouns anyways.

Dec 21, 2023, 14:21 by programm...@jsoftware.com:

> Not quite though. Had I 5 hands, that'd be !4 booleans.
>
>
> Dec 21, 2023, 14:11 by programm...@jsoftware.com:
>
>>
>> 1 0 0 1 0 /:~ i.5
>>
>> 1 2 4 0 3
>>
>>
>>  On Thursday, December 21, 2023 at 09:03:34 a.m. EST, 'Viktor Grigorov' via 
>>Programming  wrote: 
>>  
>>  Hey,
>>
>> Is there an easy way to sort an array with verb  returning either 0 or 1, 
>> like the comparison primitives? 
>>
>> The verb that I'd in mind relates to the 2023's advent of code's day 7: 
>> given two equal length hands, which one has the first high card. Which one 
>> can write as:
>>
>>    'K2345' ( 2 | 0 { [: I. [: , [: (<,.>)/ ,: & ('23456789TJQKA'i.]) ) 
>> 'KJ2KA'
>> 0 NB. here meaning left is not greater right
>>
>> Cheers,
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>  
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>

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


Re: [Jprogramming] sorting using verb returing a boolean

2023-12-21 Thread 'Pascal Jasmin' via Programming
 
1 0 0 1 0 /:~ i.5

1 2 4 0 3


On Thursday, December 21, 2023 at 09:03:34 a.m. EST, 'Viktor Grigorov' via 
Programming  wrote:  
 
 Hey,

Is there an easy way to sort an array with verb  returning either 0 or 1, like 
the comparison primitives? 

The verb that I'd in mind relates to the 2023's advent of code's day 7: given 
two equal length hands, which one has the first high card. Which one can write 
as:

   'K2345' ( 2 | 0 { [: I. [: , [: (<,.>)/ ,: & ('23456789TJQKA'i.]) ) 'KJ2KA'
0 NB. here meaning left is not greater right

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


Re: [Jprogramming] Primes with combination of same digits

2023-09-23 Thread 'Pascal Jasmin' via Programming
 pf 19 has at least 1 solution

# 1 ,^:(0 = 

Re: [Jprogramming] Primes with combination of same digits

2023-09-23 Thread 'Pascal Jasmin' via Programming
 there is a bug in your p 3... 793 is not prime.
An approach that can be improved upon in speed:

perm =: i.@! A. i.

raveltillCS =: 1 : ',/^:(m < #@$)^:_' NB. repeat ravel until count of shape = m

p2 =: 1 3 7 9 ~.@:(,/^:(2 < #@$)^:_@:(/:~"1@:({ )~&:>)) (<0 1 2 3) { @:#~ ]  
NB. unique combinations(?) of digits (y is # of digits) that can form primes
pf =: (perm (] #~ 

Re: [Jprogramming] Interesting Quora Problem:

2023-09-13 Thread 'Pascal Jasmin' via Programming
 Thank you. Correct.
The theme I was proud to contribute was J's excellent tools for "successive" 
(same family as recursive) algorithms.  Insert/Fold being used here.  A concept 
I've brought up incidentally on previous occasions is that of a "Perfect 
Function"... defined as a function that returns a result of compatible shape to 
its primary (y) argument, and might meaningfully be called again on that 
argument.  These can be use with J's ^: / F. ] function family for loopless 
functional code.  Raul's F function applied repeatedly inspired my Fold 
replacement.  It was already an improvement over searching through all 
permutations.
This does improve timings
   BASE10DIVbyINDEX =: '';1 3 7 9; 2 4 6 8;1 3 7 9; 2 4 6 8;5;2 4 6 8;1 3 7 9;2 
4 6 8;1 3 7 9

 v2 =: ([ (] #~ [ = 

Re: [Jprogramming] Interesting Quora Problem:

2023-09-13 Thread 'Pascal Jasmin' via Programming
 A variation that excludes 0s, and prunes after each "iteration"

(>:i.9) ([ (] #~ [ = 

Re: [Jprogramming] Interesting Quora Problem:

2023-09-12 Thread 'Pascal Jasmin' via Programming
 lower code version, of Raul's.
I may not have understood problem, but I get 2492 solutions (oops... now I 
understand that each digit needs to be used just once.
I =: ]F.: NB. insert using fold for shape flexibility

#(>:i.9) ([ (] #~ 0 = |) (i.10) +("1 0)(,@:) 10 * ])I 9 8 7 6 5 4 3 2


 # (>:i.9) ([ (] #~ 0 = |) (i.10) +("1 0)(,@:) 10 * ])I 9 8 7 6 5 4 3 2
2492

5 {. (>:i.9) ([ (] #~ 0 = |) (i.10) +("1 0)(,@:) 10 * ])I 9 8 7 6 5 4 3 2

102000564 102006162 102006801 102006882 102054402

with spec, but 0 allowed to be included in distinct digits

 (#~ 9 = 

Re: [Jprogramming] integers occur in integers?

2023-08-26 Thread 'Pascal Jasmin' via Programming
 
3 2 1(*./@:(e.~)&~.&(/:~) 

Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.

2023-08-11 Thread 'Pascal Jasmin' via Programming
 if you (or a user) are calling your function from J code, add the x to any 
"literal numbers".
If your very large number is the result of a calculation, then you can ensure 
that it is returned as extended.
If the input comes from elsewhere/other program, then pass it as a string.
 
".@,&'x' '1239810239812039812039812039180319283019283'

1239810239812039812039812039180319283019283


On Friday, August 11, 2023 at 08:29:47 p.m. EDT, Ak O  
wrote:  
 
 For me,
(x: y)
does not preserve the input.

The result I get is not the same.


          ( x:180548043269214561950911457875657 )
 180548043269214573494164592263168
This does not work.



          180548043269214561950911457875657x
180548043269214561950911457875657
This does work.





On Fri., Aug. 11, 2023, 13:01 Henry Rich,  wrote:

> (x: value) produces extended version of value.
>
> Henry Rich
>
> On Fri, Aug 11, 2023, 2:44 PM Ak O  wrote:
>
> > Hi everybody, I hope you are all well.
> >
> > I have a question about the Anagram ( A. ) operator.
> >
> > In a defined function, how do I designate that an input 'x' is treatment
> > as  extended datatype rather than float?
> >
> > Where being defined:
> >      13 : ' x A. i.y'
> > [ A. [: i. ]
> >
> >  is to be taken as,
> >      13 : 'X_INPUTx A. y'    NB. 12345672345467x A. i.y
> >
> > How do I get the affect of catenating an 'x' to the end of a number in a
> > defined function?
> >
> > If you understand my question ignore below, otherwise I give an example.
> >
> > Thank you for your thoughts.
> >
> > Ak
> >
> >
> > My understanding of the Anagram operator (A.).
> > The vocabulary reference page (acapdot) gives the product of the Anagram
> > index function
> >    A. y
> > as datatype extended.
> >
> >
> > The Anagram function
> >    x A. y
> > applies the permutation map (x) on  ordered vector sequence (y) as below.
> >
> >
> > ]    vector_sequence =:      ?~30
> > 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5
> > 16 14
> >
> >
> > ]    vector_anagram =:    A. vector_sequence
> > 180548043269214561950911457875657
> >
> > The Noun, vector_anagram will have datatype extended, given by:
> >    datatype vector_anagram
> > extended
> >
> > Applying the vector_anagram on a vector using the command:
> >      vector_anagram A. i.30
> > 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5
> > 16 14
> >
> > The expected result.
> >
> > In a case where the digits are input on there own, the following fails
> with
> > 'domain error, executing dyad A.'
> >
> >      180548043269214561950911457875657 A. i.30
> >
> > One approach is to place 'x:' before the input.
> >      ( x:180548043269214561950911457875657 )A. i.30
> > 20 12 4 29 7 17 22 11 2 27 28 25 1 8 0 15 16 14 3 5 19 26 18 6 21 23 13
> 24
> > 9 10
> >
> > This is not the expected result.
> >
> > The input is treated as 180548043269214573494164592263168.
> >
> >      ( x:180548043269214561950911457875657 )
> > 180548043269214573494164592263168
> >
> > Not the input I thought I was applying.
> >
> > An alternative is to postfix an 'x' to the end of the input.
> >      180548043269214561950911457875657x A. i.30
> > 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5
> > 16 14
> >
> > The expected result. But how do I achieve this for a defined function.
> >
> > Does not work either.
> > ".@((":vector_anagram),x')"_    NB. same as x:
> >
> >
> > Maybe there is a symbol that 13 : can be recognize to trigger the
> extended
> > datatype.
> >
> >
> >
> > Thank you for your help.
> >
> > Ak
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
For information about J forums see http://www.jsoftware.com/forums.htm
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Explicit to tacit conversion without repeating verbs

2023-08-10 Thread 'Pascal Jasmin' via Programming
 A general version of approach 1 is to append any temporary results to original 
argument in boxed form.

G0 =: 0 {:: ]
G1 =: 1 {:: ]G2 =: 2 {:: ]

[:  (G2 V~ G1 U G0 )  [ ( [ (] (,<)~ W) G1) ] ,&< Q
Can be streamlined a bit with:

NB. keeps y argument, though ensures it is boxed, and appends result of u to 
(boxopen y)
K =: 1 : '(boxopen@]) (, <) u'

[:  (G2 V~ G1 U G0 ) [ (W G1)K Q K
On Thursday, August 10, 2023 at 10:48:01 a.m. EDT, Raul Miller 
 wrote:  
 
 1) yes, but it might not be a good idea. (You can form x and y into a
sequence which can be passed as a single argument, and then extract
arguments from that sequence.)

2) If Q is expensive to compute, I am aware of two other options:

(a) use a name to refer to its result (as you have done here), or

(b) use the memoize (M.) adverb (assuming Q's arguments are
sufficiently constrained).

You might also combine (a) and (b) by constructing your own
reinterpretation of the M. adverb if that suits your design.

--
Raul



On Thu, Aug 10, 2023 at 9:14 AM Marcin Żołek
 wrote:
>
> Let U, V, W, P, Q be dyads and
>
> F =: dyad define
>    (tmp U y) V x W y P tmp =. x Q y
> )
>
> Tacit form of F, for example, is
>
> F =: (Q U ]) V [ W ] P Q
>
> but in this definition Q is repeated.
>
> 1. Is it possible to convert definition of F to tacit form without repeating 
> Q in definition?
> 2. Does the interpreter recognize repetition of Q and evaluate Q only once? 
> How to make the interpreter not evalute Q twice?
>
> Thanks,
> Martin
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Filling in Missing Parts of a Sequence

2023-07-24 Thread 'Pascal Jasmin' via Programming
 I have a kv library, I published before. It includes (kvinsert) an ordered 
insert function to permit arbitrary order, but its design and testing may need 
improvement.  In this case, it seems that appending then sorting represents the 
order that you want.  In kv library append also updates when searching by key 
(last key added is "the key")
  (3 5 ,. 11 12) /:~@:,~ 1 2 4 6 7 ,. 4 6 3 8 5


1 4

2 6

3 11

4 3

5 12

6 8

7 5



On Monday, July 24, 2023 at 06:06:00 a.m. EDT, 'Mike Day' via Programming 
 wrote:  
 
 Elijah's reply offers lots of ideas, with thoughts about filling histogram 
results.
However, this might also be of interest:

  xs  NB. a small example
1 2 4 6 7
4 6 3 8 5
  expand NB. I think this is included in J at startup
#^:_1
  expxs =: {{ix,:y expand~x e.~ix=. >:i. {:x}}/
  expxs xs
1 2 3 4 5 6 7
4 6 0 3 0 8 5

This follows your apparent requirement to use origin 1. It would need refining 
if you 
wished the expanded x to start with  {.x rather than 1 .

Cheers,

Mike

Sent from my iPad

> On 24 Jul 2023, at 03:03, Fr. Daniel Gregoire  
> wrote:
> 
> Hi!
> 
> (Apologies if this is a double-post, I believe I sent it before I was
> officially on the mailing list, and I don't see it in the archives).
> 
> Given:
> 
> |:xs
> 
> 1  23
> 2    4
> 3    5
> 4  10
> 5  397
> 6    3
> 7  190
> 8  44
> 9    4
> 10    5
> 11  13
> 12 1011
> 13  10
> 14 1119
> 15  72
> 16    1
> 17    1
> 19    6
> 21    3
> 22    2
> 23    1
> 26    2
> 28    2
> 29    2
> 30    1
> 31    2
> 
> 
> I'd like $xs to be 2 31 but you can see that 18, 20, 24, 25, and 27
> are "missing".
> 
> 
> I'd like to "fill the holes" so the first row of xs is all the
> integers 1 through 31 sequentially, and to put corresponding zeros in
> the second row where I've filled the holes in the first.
> 
> 
> My thoughts have centered around using (1+i.31),.31#0 to have a 2 by
> 31 array with all zeros in the second row, and then shifting my
> original to find the non-sequential parts with something like:
> 
> 
> (1|.{.xs) - {.xs
> 
> 
> But then I'm struggling to reason about a non-loopy way to put it all
> together. Any help is greatly appreciated.
> 
> 
> Kind regards,
> 
> Daniel
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Question

2023-07-11 Thread 'Pascal Jasmin' via Programming
 Not sure it is supported, however,
You can paste in a script into edit window,
and you could paste the content of an aribitray file into a 0 : 0 multiline 
noun defintion.
On Tuesday, July 11, 2023 at 01:50:10 p.m. EDT, 'robert therriault' via 
Programming  wrote:  
 
 Hi charles,

The 'J Playground' or'J in a browser' is supported by WASM so it runs the J 
engine on your browser. It was meant to provide a lightweight option for people 
to try J out and not meant to do the same work as the J engine running under 
the console, JQt or JHS environments. That does not mean that what you are 
asking for is not possible - others with more proficiency may suggest ways to 
accomplish the task. I would suggest though that the easiest way to accomplish 
the task you want is to download J and use one of the console, JQt or JHS 
environments that are set up to do exactly what you want.

Hope this helps and welcome to the J community.

Cheers, bob

> On Jul 11, 2023, at 10:35, charles holder  wrote:
> 
> How do I *read from/write to* a file on my computer in *J in a browse*r?
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] how to apply the same adverb repeatedly ?

2023-06-13 Thread 'Pascal Jasmin' via Programming
 my version of this with new 903 trains,
eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : m'
isNoun =: (0 = 4!:0 ::0:)@:<
aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' '
vm2c =: APPLY =: 2 : ' u n' NB. verb to monad applied to n

 9 

Re: [Jprogramming] Fwd: Adverb in parsing table

2023-06-11 Thread 'Pascal Jasmin' via Programming
 I'll just add, 
for the adverbs that return verbs, and / is a good example.
The monadic case of u/ uses a dyadic u to insert u into arguments of the 
"resulting verb" u/
For dyadic/table case of /  it is [x] u/ y, the presence of x that applies the 
dyadic case to the u/ resulting verb.
It is noteworthy that perhaps the bivalent / should not have been implemented 
this way.  dyadic / is equivalent to u"_1 _.  Perhaps dyadic / could have been 
implemented as ]F.: all along.
The guide to parsing adverbs is that an adverb only looks at its main/only 
argument in order to return something.  If that something is a verb, then it is 
bivalent and needs to react to both calling conventions.  In an explicit (or 
just using : in tacit) adverb definition, you have the option to define both 
valences independently.
On Saturday, June 10, 2023 at 05:40:20 p.m. EDT, Raul Miller 
 wrote:  
 
 Adverbs are never dyadic. Nor are they monadic in the sense that verbs
are monadic. (An adverb takes a single left argument, a monadic verb
takes a single right argument.)

If the result of the adverb is a verb (which is the case for built-in
adverbs, and many user defined adverbs), the resulting verb will carry
up to two definitions -- a monadic definition and a dyadic definition.
Which definition gets used depends on how that verb is used. If the
verb is used in a context where it doesn't have a definition, you get
an error.

I hope this makes sense,

-- 
Raul

On Sat, Jun 10, 2023 at 5:36 PM Raoul Schorer  wrote:
>
> Hello,
>
> When an adverb is executed, it should follow line 3 of the parsing table (
> https://www.jsoftware.com/help/jforc/parsing_and_execution_ii.htm ). But:
>
>
>    - How does the interpreter know if it should execute the 'monadic' vs.
>    'dyadic' adverb, e.g. 'infix' or 'table' in the case of '/' ?
>    - And how does the interpreter infer the definite resulting
>    part-of-speech? Is there a check testing whether the result of the adverb
>    application is a procedure, and if so its arity?
>
>
> The documentation states that "In all cases the word replacing the fragment
> has a definite part of speech, and if it is a verb, a definite rank". How
> this is achieved for all cases with an adverb is non-obvious to me...
>
> Thanks!
> Raoul
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Multiline comment

2023-05-24 Thread 'Pascal Jasmin' via Programming
 Note 'title'comment line 2comment line 3
)
On Wednesday, May 24, 2023 at 06:37:29 a.m. EDT, 'Rob B' via Programming 
 wrote:  
 
 Hi,

A few days ago I thought I saw something about multiline comments

eg NB. 1…..

I cannot find anything about it now, was it a dream?

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


Re: [Jprogramming] sequential machine and empty word output

2023-04-24 Thread 'Pascal Jasmin' via Programming


> parsing a csv file with 3 fields per record where any can be empty:

This is indeed an important application, and missing capability of ;:.

discussion: 
https://code.jsoftware.com/wiki/User:Pascal_Jasmin/sequential_machine_intro 

A workaround to emit nulls part of jpp package (whole project must be loaded to 
use).

https://github.com/Pascal-J/jpp/blob/master/fsm.ijs

asserts at bottom show "preprocessing approach" for embedding null results.

but an emit empty word code would be simpler/faster.










   









On Monday, April 24, 2023 at 05:34:23 a.m. EDT, Danil Osipchuk 
 wrote: 





I wonder if I'm the only one bothered by semicolon's assertion of strictly
i>j.

Generally, empty words can be used as markers to impose some additional
regularity on the output, to make it easier to process later.

An obvious example would be parsing a csv file with 3 fields per record
where any can be empty:
,,
,1st field, Is empty
Full record, 3, "Hello, world"

It is natural to parse it into empty strings where appropriate, but i>j
gets into a way.


Letting i>:j in and adding 3( for the sake of completeness) new opcodes
like below seems to be increasing SM's usefulness considerably in mostly
backwards compatible way. What do others think?

8    j=.i+1
9    j=.i+1  [ ew(i,j,r,c)
10  j=.i+1  [ ev(i,j,r,c)

NB. Rows: 0: Waiting for terminating comma, 1: Inside of quotes
NB. Columns: 0: comma, 1: double quotes, 2: other

  <"1 (2 3 2$ 0 9 1 1 0 0  1 0 0 0 1 0)
+---+---+---+
|0 9|1 1|0 0|
+---+---+---+
|1 0|0 0|1 0|
+---+---+---+
  csv =: (0;(2 3 2$ 0 9 1 1 0 0  1 0 0 0 1 0  );(',';'"');0 0 0 _1 ) &
;:
  csv ',,'



  csv ',1st field, Is empty'
++-+-+
||1st field| Is empty|
++-+-+
  csv 'Full record, 3, "Hello, world"'
+---+--+--+
|Full record| 3|"Hello, world"|
+---+--+--+



dlab:~/Sources/jsource-master/jsrc$ diff w.c w.c.orig
251c251
< #define CHKJ(j)            ASSERT(BETWEENC((j),0,i),EVINDEX);
---
> #define CHKJ(j)            ASSERT(BETWEENO((j),0,i),EVINDEX);
272,274d271
<  case 8:        j=i+1; break;
        \
<  case 9:        if(0<=vi){EMIT(T,vj,vi,vr,vc); vi=vr=-1;}
EMIT(T,j,i,r,c);        j=i+1; break;  \
<  case 10:        if(r!=vr){if(0<=vi)EMIT(T,vj,vi,vr,vc); vj=j; vr=r;
vc=c;} vi=i;  j=i+1; break;  \
339c336
<  v=sv; DQ(p*q, k=*v++; e=*v++;
ASSERT((UI)k<(UI)p&&(UI)e<=(UI)10,EVINDEX););
---
>  v=sv; DQ(p*q, k=*v++; e=*v++;
ASSERT((UI)k<(UI)p&&(UI)e<=(UI)7,EVINDEX););
346c343
<  if(2<=n){ijrd[1]=j=*v++; ASSERT(BETWEENC(j, -1, i),EVINDEX);}
---
>  if(2<=n){ijrd[1]=j=*v++; ASSERT(BETWEENO(j, -1, i),EVINDEX);}


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


Re: [Jprogramming] Problem with integer arithmetic

2023-04-17 Thread 'Pascal Jasmin' via Programming
 > Example: 5 % m. 7 (9) gives 5 *(mod 7) (inverse of 9(mod 7))
example is not clear to me:
is 5 % m. 7 (9)

7 | 5 % 9  NB.?
I don't understand % as a typical application of modular arithmetic.  
On Monday, April 17, 2023 at 02:56:28 p.m. EDT, Henry Rich 
 wrote:  
 
 In the next beta u m. n means 'u(mod n)' and will work for + - * % ^ .  
%. coming soon.

The only specials I see with m&| are m&|@^ and m&|@(n&^) which can be 
replaced by [n] (^ m. m) y.

Example: 5 % m. 7 (9) gives 5 *(mod 7) (inverse of 9(mod 7))

Henry Rich

On 4/17/2023 2:07 PM, 'Michael Day' via Programming wrote:
> u m. n ?  I thought m. disappeared many versions ago, along with x. y. 
> etc !
> Could you provide an example?    And is m&|@u deprecated for other 
> verbs u ?
>
> Float results would be helpful.  Presumably an array would be returned 
> as float
> if at least one element needed to float,  as usual.
>
> Thanks again,
>
> Mike
>
> On 16/04/2023 17:15, Henry Rich wrote:
>> I think I have figured out a way to return float when the result has 
>> been
>> made inaccurate.
>>
>> We had no choice about m&|@^ for negative y: the behavior of that is
>> defined by the language, and it isn't modular.
>>
>> u m. n is a much cleaner solution, and faster. m&|@^ is deprecated.
>>
>> Henry Rich
>>
>> On Sun, Apr 16, 2023, 11:51 AM 'Michael Day' via Programming <
>> programm...@jsoftware.com> wrote:
>>
>>> Thanks for this and your previous comment re  (-:<.@*<:)
>>> I'm afraid I've only just noticed this later reply in my J mail folder.
>>>
>>> I was going to grumble about x!y remaining integer even when the value
>>> might be wrong.
>>> Perhaps you or others might think of a suitable warning comment in 
>>> NuVoc
>>> about dyadic !  .
>>> 2!y could perhaps be treated as special case,  being a triangular
>>> number,  y(y+1)/2 where
>>> one could right shift whichever of y, y+1 is even, but presumably that
>>> would involve too
>>> much overhead.   Caveat Calculator,  I suppose.
>>>
>>> BTW,  I see you've decided against implementing x m&|@^ y for negative
>>> integer y, integer x,
>>> and extended m.   (Though I don't remember m needing to be extended in
>>> earlier discussions!)
>>> A pity,  but it's been useful to learn that the idiom is well supported
>>> for positive y.
>>>
>>> Cheers,
>>>
>>> Mike
>>>
>>> On 14/04/2023 14:22, Henry Rich wrote:
 As (x!y) is coded, the calculation is done in floating-point and then
 converted to integer if the result will fit.  Loss of significance
 during the calculation will make the result inaccurate.

 I think it's a JE error to return an integer value when that value
 might be wrong.  Unfortunately, the way the internal interfaces are,
 it's difficult to leave the value as floating-point, so you cannot use
 the fact that an integer was returned as a guarantee of accuracy.

 Henry Rich

 On 4/13/2023 11:34 AM, 'Michael Day' via Programming wrote:
> Yet again I found myself resorting to Pari GP for a calculation;  my
> J function had been giving
> correct answers to a problem for lowish inputs,  but apparently gave
> up at some stage for
> higher values;  I then coded the calculation in Pari GP which gave
> the same results for low
> inputs,  but diverged from J at the business end.
>
> Looking for inconsistencies between the two functions, the
> divergence seems to appear
> around this case:
>
> m =. 134235395
>     2^.m NB. plenty of room for multiplication in 64-bits???
> 27.0002
>
>     2!m
> 9009570568285316
>     datatype 2!m
> integer
>
>     (-:<.@*<:)m
> 9009570568285316
>     ((*<:)m)<.@%2
> 9009570568285315
>     _1 (33 b.) (*<:)m
> 9009570568285315
>
>     datatype (*<:)m
> integer
>
> So - why am I getting 2!m returned as integer but wrong? If there's
> overflow,
> why isn't it a float?  Why does    (-:<.@*<:)m return the wrong
> integer when
>     ((*<:)m)<.@%2   yields the correct integer?
>
> This was in J.04,
> Engine: j9.4.2/j64avx2/windows
> Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1
>
> I haven't checked behaviour in earlier releases.  I didn't try
> extended integers
> for this problem.
>
> Thanks,
>
> Mike
>
>
>
> -- 
>
> For information about J forums see 
> http://www.jsoftware.com/forums.htm
 --
 For information about J forums see http://www.jsoftware.com/forums.htm
>>> --
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>> --
>> For information about J forums see 

Re: [Jprogramming] distance makes the heart grow fonder

2023-04-02 Thread 'Pascal Jasmin' via Programming
 label_. currently serves line splitting function in explicit code.  Shortening 
that to .. equivalent "is easy".
functionality that would appeal to me from a "special word" (not conj/adv or 
other speech) is as a separator that acts as parentheses, and works with tacit 
code:
myfunction =: exp1 .. exp2 NB. .. leading on next line indicates a line join 
instead of a split, with this comment stripped from full expression .. exp3

would be equivalent to
myfunction =: ((exp1) (exp2)) (exp3)  NB.  where .. line joining start of line 
indicator also parenthesizes full prior expression.

a trailing (right) dangling .. would not parenthesize the previous expression.
I'll note that embedding a comment anywhere is pretty easy with:
NB =: 2 : 'u'
+/ NB 'sum' 1 2 3 NB commentwordunquoted
6


+/ [. 'sum' 1 2 3 NB. 903 equivalent.

6

I've posted about jpp extensions that I've made that reduce quoting and 
parenthesizing.  I make heavy use of separator (non speech).  I hijack ` an use 
"ti" as a gerund builder.  It might be better than this proposal.

On Saturday, April 1, 2023 at 09:52:33 a.m. EDT, Raul Miller 
 wrote:  
 
 Control words also work as line separators.

So introducing a no-op control word (perhaps a single letter followed
by a dot) would scratch most of that itch.

Making control words work outside of explicit definitions (either this
single example, or maybe a more complete entourage) would require more
extensive changes, comparable in scope perhaps to the [{ }} effort.
But maybe that's worth doing also?

As for a line joiner... I'm tempted to suggest nb. followed by
arbitrary text which would be ignored. My experience with multi-line
expressions is that it becomes quite annoying to comment them. And we
could head that off by making the line joiner also be a comment to
end-of-physical-line "token".

The line joiner would also be "explicit only" unless (at least some)
explicit syntax was allowed at the command line.

Thanks,

-- 
Raul

On Sat, Apr 1, 2023 at 5:26 AM Elijah Stone  wrote:
>
> Some time ago, Michal proposed that a line separator be added.  I want to
> rekindle that discussion.  The proposal was that .. behave like a line break
> when placed on a single line, such that e.g. {{ a=. y+y .. a }} 2 would do the
> obvious thing.  Short, distinctive, and to the point.
>
> I also want to propose a line _joiner_, analogous to \ in shell or c: ...,
> placed at the beginning or end of a line should join it with the previous or
> next.  Joining lines happens _after_ stripping comments, unlike the other
> languages I cited; the goal is to enable large, multi-line definitions with
> commentary for intermediate terms, without the need for pointless intermediate
> definitions.
>
> It might be objectionable to use such similar symbols for separators and
> joiners.  But maybe it's not such a big deal.  Two more ideas:
>
> 1. Could use the _same_ symbol for both, with its sense depending on where
> it's placed in a line.
>
> 2. Separator could be .:.; metaphor: a hill stops the interpreter in its
> tracks.
>
> I don't like 2 because the larger the separator is, the more annoying it is to
> use.  Joiner can afford to be large, since it only comes into play if the rest
> of the line is sufficiently large.
>
> Anyway--thoughts?  Comments?  Suggestions?
>
>  -E
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Applying a cyclic gerund

2023-02-21 Thread 'Pascal Jasmin' via Programming
there is

G1 =: 1 {:: ]
G0 =: 0 {:: ]


(G0 ; ".@G1) 'abc';'13.2'




On Tuesday, February 21, 2023 at 11:18:21 p.m. EST, Elijah Stone 
 wrote: 





Your routine most likely doesn't do what you want it to:

    'abc ' -: 0{:: (<@:])`(<@:".)"1 >'abc';'13.2'
1

The 'abc' got padded when you opened.

You could go for ]`(".&.>)"1.  Or {{y 1}~ ".&.> 1{y}}.  I don't expect you're 
likely to find anything much nicer.

(Had j structural under, you might say ".&.(1&{::), but it does not.)

On Tue, 21 Feb 2023, Gilles Kirouac wrote:

> I have two character strings :
>
>    datatype each 'abc';'13.2'
> ┌───┬───┐
> │literal│literal│
> └───┴───┘
>
> I want to convert the second one into numerical data
>
>  datatype each (<@:])`(<@:".)"1 >'abc';'13.2'
> ┌───┬┐
> │literal│floating│
> └───┴┘
>
> Can you simplify the above expression?
>
>
> ~ Gilles
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Odd

2023-02-16 Thread 'Pascal Jasmin' via Programming


There is also a numeric library install required (forget which one) that while 
it shouldn't crash without it, will not produce extended results.




On Thursday, February 16, 2023 at 10:31:45 p.m. EST, bill lam 
 wrote: 





We have received reports on the crash but can't reproduce by ourselves.
Would you give detail of the 2 computers such
linux distro name and version, and
version of glibc (  ldd --version)

On Fri, Feb 17, 2023 at 11:22 AM Omar Antolín Camarena <
omar.anto...@gmail.com> wrote:

> >  And it no longer crashes.
>
> There's a little bit of luck involved in that. I use J on two computers, on
> one j904 works just fine but on the other doing anything at all using
> extended integers makes it crash.
>
>
> On Thu, Feb 16, 2023 at 9:19 PM Mike Duvos  wrote:
>
> > Thanks.  I got j904 installed from the zips.  Surprisingly, it is up to
> 58
> > times faster doing modular exponentiation on large extended precision
> > integers.  And it no longer crashes.
> >
> > On Thu, Feb 16, 2023 at 6:24 PM Devon McCormick 
> > wrote:
> >
> > > It's probably blank because there is no all-in-one installer for 9.04.
> > > Raul is correct that you have to install it from zips.
> > >
> > > On Thu, Feb 16, 2023 at 8:24 PM Raul Miller 
> > wrote:
> > >
> > > > I don't know why there's a link to a non-existent all in one page.
> > > >
> > > > For now, I think you have to install it from a zip archive:
> > > > https://code.jsoftware.com/wiki/System/Installation/J904/Zips
> > > >
> > > > I hope this helps,
> > > >
> > > > --
> > > > Raul
> > > >
> > > > On Thu, Feb 16, 2023 at 7:50 PM Mike Duvos  wrote:
> > > > >
> > > > > I went to the Wiki page for j904 and clicked on the all-in-one
> > > installer
> > > > > for Windows, and it took me to a Wiki page with nothing on it.  Do
> I
> > > have
> > > > > to install it some other way?
> > > > >
> > > > >
> > > > >
> > > > > On Thu, Feb 16, 2023 at 3:32 PM Raul Miller  >
> > > > wrote:
> > > > >
> > > > > > When I run (genkey 32) under j903, I get a crash.
> > > > > >
> > > > > > When I run (genkey 32) under j904, it works fine.
> > > > > >
> > > > > > A number of issues have been addressed in j904 (and it's almost
> > ready
> > > > > > for release). It might be worth upgrading.
> > > > > >
> > > > > > --
> > > > > > Raul
> > > > > >
> > > > > > On Thu, Feb 16, 2023 at 6:21 PM Mike Duvos 
> > wrote:
> > > > > > >
> > > > > > > I installed it a few weeks ago from the link in the wiki to the
> > > most
> > > > > > recent
> > > > > > > stable version.  If I click on “about” in jqt , it says…
> > > > > > >
> > > > > > > Engine: j903/j64avx2/windows
> > > > > > >
> > > > > > > It said the beta was for “adventurous users.”
> > > > > > >
> > > > > > > Should I be running a different one?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Thu, Feb 16, 2023 at 3:01 PM Elijah Stone <
> > elro...@elronnd.net>
> > > > > > wrote:
> > > > > > >
> > > > > > > > What version of je are you running?  I get innocuous results:
> > > > > > > >
> > > > > > > >    genkey 32
> > > > > > > > 15970092203996114281 4061548213 3932020837
> > > > > > > >    genkey 32
> > > > > > > > 14979749644274477941 4038627851 3709118591
> > > > > > > >    genkey 32
> > > > > > > > 15125320685289546439 3974107847 3805966337
> > > > > > > >
> > > > > > > > If you are not running the latest beta, I suggest doing so;
> > among
> > > > other
> > > > > > > > things, support for extended-precision numbers was much
> > improved.
> > > > > > > >
> > > > > > > > On Thu, 16 Feb 2023, Mike Duvos wrote:
> > > > > > > >
> > > > > > > > > I wrote a brief J script to generate random RSA keys in
> > various
> > > > > > > > lengths.  I
> > > > > > > > > put a copy in my Dropbox at the following URL…
> > > > > > > > >
> > > > > > > > > https://www.dropbox.com/s/0y0tpgtjtv4vvd2/rsakeys.ijs
> > > > > > > > >
> > > > > > > > > In this script is a function called “genkey” which crashes
> J.
> > > > > > > > >
> > > > > > > > > genkey =: 3 : 0"0
> > > > > > > > >
> > > > > > > > > q =. p =. randprime y
> > > > > > > > >
> > > > > > > > > while. q = p
> > > > > > > > >
> > > > > > > > > do.
> > > > > > > > >
> > > > > > > > > q =. randprime y
> > > > > > > > >
> > > > > > > > > end.
> > > > > > > > >
> > > > > > > > > if. p < q
> > > > > > > > >
> > > > > > > > > do.
> > > > > > > > >
> > > > > > > > > 'p q'=. q,p
> > > > > > > > >
> > > > > > > > > end.
> > > > > > > > >
> > > > > > > > > (p*q),p,q
> > > > > > > > >
> > > > > > > > > )
> > > > > > > > >
> > > > > > > > > randprime y returns a random prime of length y bits with
> the
> > > > upper
> > > > > > two
> > > > > > > > bits
> > > > > > > > > set as an extended precision integer.  It seems rock solid
> > and
> > > > has
> > > > > > been
> > > > > > > > > called millions of times without issue.
> > > > > > > > >
> > > > > > > > > genkey picks a prime, p, and another prime not equal to it,
> > q,
> > > > and
> > > > > > swaps
> > > > > > > > > them if necessary so p is the 

Re: [Jprogramming] Atop parsing

2023-02-16 Thread 'Pascal Jasmin' via Programming
Beautiful.

this is the CC(nv) pattern, that matches the CA pattern.

The elegance that allows that allows for elegance in making "compounder" 
modifiers.




On Thursday, February 16, 2023 at 12:28:24 p.m. EST, David Lambert 
 wrote: 





Of the new modifier trains, I've found ^:^:_ as "while".  A simple test 
code: increment while less than 8.  (With some errors one need kill the 
j session.)

   >: (^:^:_) (<&8) 2

8

   While=: ^:^:_

   u. While v.
u.^:v.^:_

> Date: Wed, 15 Feb 2023 13:12:37 +0100
> From: Jan-Pieter Jacobs
> To:programm...@jsoftware.com
> Subject: Re: [Jprogramming] Atop parsing
> Message-ID:
>     
> Content-Type: text/plain; charset="UTF-8"
>
> The reason it's hard to find anything else on modifier trains is that they
> have been removed from the language a long time ago (with j501 in 2002,
> apparently), and only reintroduced recently with j903.
>
> Before the reintroduction, the only modifier trains were bidents:
> - partially applied conjunctions, yielding adverbs; and
> - chained adverbs, being applied to their left argument in order.
> They were left over because they are simple, intuitive and easy to remember
> (guessing here, as I wasn't around in the J scene yet).
> These are explained well inhttps://www.jsoftware.com/help/learning/15.htm  .
> The adverbs each and every defined in the standard library library are
> useful examples of the first kind of bidents:
>    type&.<'each'
> adverb
>    each
> &.>
>
> The rabbit hole of general modifier trains is deep: they are not completely
> intuitive (at least to me) and require a thorough understanding of the
> parsing and execution in J, especially when chaining more than three. They
> are also not indispensable, as you can write explicit conjunctions and
> adverbs to do anything such tacit modifiers would do. I have yet to find a
> useful, non-trivial purpose for them... Of course, feel free to use them if
> you like the challenge, but there are far more important areas to get to
> know in J, like rank. Or all the wonderful labs (in the menu, help > studio
>> labs).
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Atop parsing

2023-02-15 Thread 'Pascal Jasmin' via Programming
All, but 1 or 2 of https://code.jsoftware.com/wiki/Vocabulary/ModifierTrains 
are extremely useful.  Their use is mainly in creating compound modifiers 
(expressions that return modifiers) or quick modifiers.

The core "adverbial programming" in J has always been the much simpler adverb 
sequence train

AAA...AA

which extends to

A(uC)A(Cv)...AA  NB. uC and Cv are adverbs resulting from bound conjunctions.


Another core J concept to adverbial programming is that of the verb phrase.

u1 C1 v1 C2 v2  NB.  a verb phrase is a/results in a verb. More generally, 
fully bound modifier.  noun phrase is the same concept.

A frequent source of errors in my J career is that the above parses as:

(u1 C1 v1) C2 v2  NB. when I could have intended u1 C1 (v1 C2 v2)


C1 binds just to v1 instead of the whole verb phrase to its right.

The approach I used in myvarp3 is one meant to enhance editability of 
expressions

v1 (u1 C1) C2 v2  NB. original

v1  C2 v2 (u1 C1) NB. edit for "intent"

The key issue with parentheses is that they are more readable/editable the 
shorter they are and especially the less nested embedding there is.

In above examples u1 v1 v2 can be edited/expanded into longer verb phrases.  
Constructing (u1 C1) lets you move it as a short block to where it will "best 
apply".  It is fairly easy to recognize it as an adverb.

So in a longer expression, where laziness could miss intent.

v2 C3 v3 (v1 C2) (u1 C1)  NB. much cleaner than:

u1 C1 (v1 C2 (v2 C3 v3))  NB. nested mess.

Basically the first style allows simpler editing.  Even if the intent were

u1 C1 (v1 C2 v2) C3 v3 ,

v2 (v1 C2) (u1 C1) C3 v3  NB. moving a single continuous block of code (from 
previous section) to achieve new intent.




On Wednesday, February 15, 2023 at 07:12:52 a.m. EST, Jan-Pieter Jacobs 
 wrote: 





The reason it's hard to find anything else on modifier trains is that they
have been removed from the language a long time ago (with j501 in 2002,
apparently), and only reintroduced recently with j903.

Before the reintroduction, the only modifier trains were bidents:
- partially applied conjunctions, yielding adverbs; and
- chained adverbs, being applied to their left argument in order.
They were left over because they are simple, intuitive and easy to remember
(guessing here, as I wasn't around in the J scene yet).
These are explained well in https://www.jsoftware.com/help/learning/15.htm .
The adverbs each and every defined in the standard library library are
useful examples of the first kind of bidents:
  type&.<'each'
adverb
  each
&.>

The rabbit hole of general modifier trains is deep: they are not completely
intuitive (at least to me) and require a thorough understanding of the
parsing and execution in J, especially when chaining more than three. They
are also not indispensable, as you can write explicit conjunctions and
adverbs to do anything such tacit modifiers would do. I have yet to find a
useful, non-trivial purpose for them... Of course, feel free to use them if
you like the challenge, but there are far more important areas to get to
know in J, like rank. Or all the wonderful labs (in the menu, help > studio
> labs).

Good luck on your journey!
Jan-Pieter


Op wo 15 feb. 2023 om 04:36 schreef More Rice 

> Thank you for taking the time to explain at the level you knew I could
> digest. It is really helpful - I can now use @ vs @: in very practical
> ways.
>
> And the bonus ...
>
> The myvarp3 is so much more readable I wondered why I never came across
> such construction.  It puzzled me the entire night as to what I'm looking
> at.
>
> In NuVoc, conjunction's behaviour is described with both left and right
> operands present. I have never seen one of their operands missing in their
> description (as to what this case they would do).  The closest thing I
> found in the end is this:
> https://code.jsoftware.com/wiki/Vocabulary/ModifierTrains
>
> "A0 A1" (my guess for myvarp3) is just one of many possibilities to
> construct trains.
>
> It is a beautiful discovery.
>
> Unfortunately the material written there is too advanced for a Journeyman
> like me. I couldn't find any J book/pdf that talks about it in a more
> digestible way ... and the j wiki only has this page.
>
> But I'm really excited about this discovery.
>
> thank you.
>
> Maurice
>
>
>
>
> On Sun, Feb 12, 2023 at 6:58 PM 'Pascal Jasmin' via Programming <
> programm...@jsoftware.com> wrote:
>
> > All conjunctions including @ bind to their right argument "tightly"
> > meaning just the one token.
> >
> > The left argument of conjunctions/adverbs is the entire verb phrase to
> the
> > left of it.
> >
> > myvarp1 uses "linear style" even if it is tacit.  `[:`  has "no binding"
> > everything to 

Re: [Jprogramming] Atop parsing

2023-02-12 Thread 'Pascal Jasmin' via Programming
All conjunctions including @ bind to their right argument "tightly" meaning 
just the one token.

The left argument of conjunctions/adverbs is the entire verb phrase to the left 
of it.

myvarp1 uses "linear style" even if it is tacit.  `[:`  has "no binding"  
everything to right will execute first, and whatever is to left will wait until 
that provides a result before the left of [: "composes" with the right.

@:, by the way, is more strictly equivalent to [:/"linear style" by ensuring 
that composition occurs on the full result of the "right expression".  (+/@:) 
will apply to full "result" of the v argument to @: .  The sum of the full 
result requires @:

A style that permits shorter parentheses groups with less nesting for 
conjunctions meant to operate on a long expression to the right, the way @, @: 
do when "emulating linear style" is to turn the conjunction into an adverb, 
placing it to the right of the "right expression".  so,

myvarp3 =:  (- +/ % #)(*:@)(+/@:) % #



On Sunday, February 12, 2023 at 04:46:35 p.m. EST, More Rice 
 wrote: 





Masters,

I understand that there is an excellent reference implementation of varp in
addons/stats/base/univariate.ijs to learn from, but I'm trying to do
exercises to solidify my understanding of using verb trains/hooks, and the
difference when using Atop.

I've 2 versions of varp.

#1 below is typical of what some of you do (credit: Bob's "Maximum
Consecutive 1's in J."  Excellent video!  Thank you. I wish there were more
of these.) - using cap when we want to string monadic verbs sequentially.
No problem there.

NB. works - using hook/fork/cap
myvarp1 =: # %~ [: +/ [: *: (-+/%#)

NB. works - using hook/fork/Atop and no cap
myvarp2  =: # %~ +/ @ (*: @ (-+/%#))


#2 above, for some reason, I need an extra pair of parentheses to the right
of the 1st @ for it to work. I don't get why.  For example, the following
is broken.

NB. It gives me a list instead :(

myvarp_broken =: # %~ +/ @ *: @ (-+/%#)


Why are they (the missing parentheses w.r.t. #2) needed?



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


[Jprogramming] n: adverb proposal (and alternatives)

2023-01-18 Thread 'Pascal Jasmin' via Programming
u n:  is to be => ([x] u y)

this happens to be the same output as the verb u.

u n: A is to be=> ([x] u y) A

Difference between left and right is that left is a contained function that (u 
n:) can be considered a conjunction where x and y are m and n parameters.  
Except that an actual conjunction must be dyadic or alternatively assume 
monadic form.  In dyadic form replacement, such a conjunction is the 
universally useful (by new old modifier trains):

v2c =: 1 : '[. u ].'  NB. turn dyadic verb into conjunction.  Useful enough to 
get v: built in.

2 + (v2c (&+)) 3

5&+

same result as (+ n: (&+)) and legal.

to use a monad verb, just make it a conjunction (2 parameters after all) 
instead of compound modifier (3 params).

vm2c =: APPLY =: 2 : ' u n'  NB. monad verb applied to n.  Legal.  m: might be 
justifiable built in.

   - (vm2c (&+)) 3

_3&+

n:  would save the burden of switching/knowing/limiting what valence u might 
be.  Very useful. 

where C is a conjunction,

u n: C is to be=> (([x] u y) C) NB. result is an adverb.

n: becomes a way to turn a C into a double adverb with m as noun parameter to 
C, as v u n: C => (v (([x] u y) C))  => ([x] u y) C v

n: (C v) follows adverb functionality.

This is also possible to replace with existing legal means... again turning 
into "some level" of conjunction:

2 (((&+)) @ ]:)1 NB. AC]:

2&+@1

c2c =: 2 :  NB. m is string of C.  returns C ignoring u and v.

2 (& ('@'c2c) ) +
2&+@

- 2 (& ('@'c2c) ) +

2&+@-

- 2 (& ('@'c2c) ) + 3

_1

there are few built in conjunctions that take m parameter (@.), and it would be 
unusual for a conjunction to take 2 noun arguments, and if a conjunction takes 
1, it is more likely to be n, and then (n: C ]:) is unlikely to have an exact 
practical analogy.  But, this CA example shows partial binding potential.

 2 (+v2c (&+)) 3

5&+

2 ('@'c2c +v2c ) 3

@5

Maybe there's no need for n: afterall.  The alternative to (n: A) (or cloak 
based 'A' oa) is

(v2c A) NB. for dyad u
(vm2c A) NB. for monad u.
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Closures; WAS: Verbs returning verbs

2023-01-18 Thread 'Pascal Jasmin' via Programming

there is something like,

f=. {{
  a=. 5
  b=. 6
  g=. (a;b) {{ ... [ 'a b' =. m  }}
  g=. a {{ ... m ... }}  NB. if fewer parameters transferred.
  a=. 7
}}



On Tuesday, January 17, 2023 at 10:58:05 p.m. EST, Elijah Stone 
 wrote: 





Basically, yes.  It's interesting that you refer to them that way; it brings 
to mind locales, which are another type of namespace, and suggests the 
possibility of unifying lexical environments with locales.  I think doing that 
would be a bad idea, though, because locales are shared mutable state, and it 
would be good to have less of that rather than more.  Hence, my proposal 
applies only to lexical scopes.

The idea is that, if I have something like:

f=. {{
  a=. 5
  b=. 6
  g=. {{ ... a ... }}
  a=. 7
  ... }}

When g (or, rather, the verb it denotes) is created, it will remember and 
carry around the lexical environment in which it was created, which includes 
an association between a and 5.  (Since g refers to a, we say that it 'closes 
over' it.  The term 'closure' comes from graph theory.)  This association is 
frozen at the time g is created; hence, it never sees a=5.  The environment is 
manifest in the AR as a list of key-value associations; users can twiddle or 
create their own environments, but should not generally have much call to.

Obviously, this comprises a break to compatibility, but the fallout seems 
fairly minor.  Such name punning would be quite confusing.

Since closure only applies to lexical variables, this breaks no use of 
globals.  EG the following, at global scope:

a=: 5
fn=: {{ ... a ... }}
a=: 7

Will work just the same as it ever did.

A question: should g close over b?  It is not referred to directly in g, but 
the latter might construct references to b using "., or a user might ask for 
it when debugging.  I vote no, because of the potential for space leaks.  g 
can include a dummy reference to b, if it really wants; and perhaps a global 
toggle can be added for debugging purposes.  (This also relates to my comment 
in github issue #153.)

What say?

  -E

On Tue, 17 Jan 2023, Henry Rich wrote:

> Is it about namespaces then?  That is indeed a vexed question.  I will 
> take this under advisement.  I will need more help I'm sure.
>
> Henry Rich
>
> On 1/17/2023 10:15 PM, Elijah Stone wrote:
>> It is the other way around--lack of closures means we must write 
>> _more_ tacit code, not less.  E.G.:
>>
>> {{
>>  a=. something
>>  {{ something referring to a }} A y   NB. doesn't work
>> }}
>>
>> Whereas:
>>
>> {{
>>  a=. something
>>  (something referring to a) A y   NB. works
>> }}
>>
>> I am proposing a mechanism to make the former work (among other things).
>>
>> On Tue, 17 Jan 2023, Henry Rich wrote:
>>
>>> I don't follow any of this thread, because I don't understand what is 
>>> missing from standard J.  I find J adequate for everything I want to 
>>> do.  What am I missing?
>>>
>>> I can see that if you want to write all-tacit code you have trouble 
>>> if you need to feed a verb result into a modifier.
>>>
>>> Suppose though that I am content with writing explicit definitions.  
>>> What do I need beyond the standard language, and for what use case?
>>>
>>> Henry Rich
>>>
>>> On 1/17/2023 9:23 PM, Elijah Stone wrote:
 (Curried modifiers, as you say, are a solution, but, again, another 
 half-solution.)

 On Tue, 17 Jan 2023, Raul Miller wrote:

> Here, I suspect that you're only getting noun values in your closure
> -- you'll have to sprinkle those noun references with something like
> `:6 if you want anything else. That's probably not a huge problem.
>
> But, thinking about this, personally I'm not seeing a lot of
> motivation for this approach, either. (What problems would this solve?
> I'm sure there are some great motivating examples out there. And
> closures certainly have a lot of popularity. But... position in a list
> can be thought of as being conceptually analogous to a variable, so it
> should be apparent that we already have some support for the
> algorithmic role of closures.)
>
> (I should perhaps also note, here, that conjunctions and adverbs which
> have verb results are self-currying.)
>
> Anyways... I'm not thinking particularly deep thoughts here -- I'm
> just reflexively reaching for motivating examples (which might assist
> in forming some of those sorts of thoughts).
>
> Thanks,
>
> -- 
> Raul
>
>
> On Tue, Jan 17, 2023 at 7:01 PM Elijah Stone  
> wrote:
>>
>> I suggest:
>>
>> [x] u &:: (k;v;k;v...) y
>>
>> Will evaluate u with bindings kvkv... (raveled) active. Should 
>> work for both
>> explicit and tacit.  Implementation is allowed to coalesce; e.g., 
>> u &:: (k;v)
>> &:: (k;v) `'' may be rendered u &:: (k;v;k;v), deduplicated, 
>> Substitution also ok; eg (f%#) &:: ('f';+/`'') becomes +/%#.
>>
>> I would like for verbs 

Re: [Jprogramming] Verbs returning verbs

2023-01-18 Thread 'Pascal Jasmin' via Programming
Distinguishing between "semi tacit" and explicit modifiers is done by whether 
the ( : string) or {{}} modifier "mentions" x and y.  If it does, it cannot 
return a non-noun.  It is a "glorified verb" with extra parameters. If it 
doesn't it has all the power of tacit modifiers.


There is no "magic explicit path" to "power" unless you mean side effects to 
assign globals to all the modifiers you want within monolithic verbs.  Then you 
would be defining useful as limited to permanent global defined modifiers/verbs 
and annonymous functions become "therefore" not useful.



On Wednesday, January 18, 2023 at 03:30:13 a.m. EST, Raul Miller 
 wrote: 





Generally speaking, in computing contexts, "powerful" is orthogonal to "useful".

Which might be related to why explicit definitions are looked down on,
by some in the J community -- It seems that they're "too powerful".

But if the problem is that explicit definitions are insufficiently
constrained, why should we want to burden tacit definitions with this
defect?

-- 
Raul

On Wed, Jan 18, 2023 at 12:40 AM 'Pascal Jasmin' via Programming
 wrote:
>
> the boxed verbs are limited.  I mentioned that I can store as ARs instead.  
> But extracting 1 verb is a verb that can be applied:
>
>    (1 {:: (('X' Cloak ("0)(<@) )) 3 4 ) 2 3 4
>
> 6 7 8
>
> Because "X cloaked" is applied "0, the results are assembled based on the 
> shape of y (i.3 3 in original example)
>
>
> > What 'major need' is my proposal not addressing?  It seems to me that it
> allows you to return non-nouns (as ARs) and execute them (using ".).
>
> ARs are nouns.  We already know how to produce ARs.  Modifiers are first 
> class, and more powerful than verbs, because they can produce non-nouns.  A 
> path to channel verb results (nouns) to modifiers (n: as I've proposed it) is 
> a path to leverage the power of modifiers.  Can do so without changing verbs 
> or modifiers.  It's a big improvement.  Or just let Cloak keep "working".
>
> The original thread for (A n) request was about attributes possibly 
> annotating a noun.  This post uses an (A APPLY n) solution to access and 
> return such decorated nouns:  
> http://www.jsoftware.com/pipermail/programming/2023-January/061916.html
>
> Closures is a new topic.  This is typically considered binding function and 
> noun, where access can change the function or noun.
>
> The basic version is Modifiers are useful.  That a verb could access its x 
> and y arguments to produce a result before feeding that to a modifier in a 
> single verb phrase is useful.  It is still mechanics of verbs returning nouns.
>
> On Tuesday, January 17, 2023 at 10:27:18 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> Your ('X' Cloak(<@)("0) i.3 3) is interesting.  It seems to display as
> an array of boxed verbs. What would be the result if you opened that?
> Can you apply all the verbs on an argument?  What is the verb rank of
> the boxed array, especially if the contents are verbs with different
> ranks? How are the results assembled?
>
> What 'major need' is my proposal not addressing?  It seems to me that it
> allows you to return non-nouns (as ARs) and execute them (using ".).
>
> Please answer these questions without reverting to your
> eval/isNoun/Cloak etc.  How your noncompliant methods work is immaterial
> to this discussion (though they are interesting); I want to learn about
> deficiencies in my proposal.
>
> I appreciate that we are all trying to make J better.  I just think that
> having verbs return non-nouns is not the way to do it.
>
> Henry Rich
>
>
>
> On 1/17/2023 10:10 PM, 'Pascal Jasmin' via Programming wrote:
> > More ways to generate ARs doesn't hurt, but its not verbs returning 
> > non-nouns, or a path (n:) to obtain non-nouns from a verb phrase, so then 
> > the proposal is not meeting a major need.
> >
> > repeating definitions,
> >
> > eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : 
> > m'
> >
> > isNoun_z_ =: (0 = 4!:0 ( :: 0:))@:<
> >
> > aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' 
> > '
> >
> > Cloak=: aar(0:`)(,^:)
> >
> > X=: 1 : 'm&+'
> >
> > to answer your hypothetical DV question, it is actually possible to box 
> > verbs.
> >
> >  'X' Cloak(<@)("0) i.3 3
> >
> > ┌┬┬───┐
> >
> > │00&+│01&+│2&+│
> >
> > ├┼┼───┤
> >
> > │3&+ │4&+ │5&+│
> >
> > ├┼┼───┤
> >
> > │6&+ │7&+ │8&+│
> 

Re: [Jprogramming] Verbs returning verbs

2023-01-17 Thread 'Pascal Jasmin' via Programming
the boxed verbs are limited.  I mentioned that I can store as ARs instead.  But 
extracting 1 verb is a verb that can be applied:

   (1 {:: (('X' Cloak ("0)(<@) )) 3 4 ) 2 3 4

6 7 8

Because "X cloaked" is applied "0, the results are assembled based on the shape 
of y (i.3 3 in original example)


> What 'major need' is my proposal not addressing?  It seems to me that it
allows you to return non-nouns (as ARs) and execute them (using ".).

ARs are nouns.  We already know how to produce ARs.  Modifiers are first class, 
and more powerful than verbs, because they can produce non-nouns.  A path to 
channel verb results (nouns) to modifiers (n: as I've proposed it) is a path to 
leverage the power of modifiers.  Can do so without changing verbs or 
modifiers.  It's a big improvement.  Or just let Cloak keep "working".

The original thread for (A n) request was about attributes possibly annotating 
a noun.  This post uses an (A APPLY n) solution to access and return such 
decorated nouns:  
http://www.jsoftware.com/pipermail/programming/2023-January/061916.html 

Closures is a new topic.  This is typically considered binding function and 
noun, where access can change the function or noun.

The basic version is Modifiers are useful.  That a verb could access its x and 
y arguments to produce a result before feeding that to a modifier in a single 
verb phrase is useful.  It is still mechanics of verbs returning nouns.

On Tuesday, January 17, 2023 at 10:27:18 p.m. EST, Henry Rich 
 wrote: 





Your ('X' Cloak(<@)("0) i.3 3) is interesting.  It seems to display as 
an array of boxed verbs. What would be the result if you opened that?  
Can you apply all the verbs on an argument?  What is the verb rank of 
the boxed array, especially if the contents are verbs with different 
ranks? How are the results assembled?

What 'major need' is my proposal not addressing?  It seems to me that it 
allows you to return non-nouns (as ARs) and execute them (using ".).

Please answer these questions without reverting to your 
eval/isNoun/Cloak etc.  How your noncompliant methods work is immaterial 
to this discussion (though they are interesting); I want to learn about 
deficiencies in my proposal.

I appreciate that we are all trying to make J better.  I just think that 
having verbs return non-nouns is not the way to do it.

Henry Rich



On 1/17/2023 10:10 PM, 'Pascal Jasmin' via Programming wrote:
> More ways to generate ARs doesn't hurt, but its not verbs returning 
> non-nouns, or a path (n:) to obtain non-nouns from a verb phrase, so then the 
> proposal is not meeting a major need.
>
> repeating definitions,
>
> eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : m'
>
> isNoun_z_ =: (0 = 4!:0 ( :: 0:))@:<
>
> aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' '
>
> Cloak=: aar(0:`)(,^:)
>
> X=: 1 : 'm&+'
>
> to answer your hypothetical DV question, it is actually possible to box verbs.
>
>   'X' Cloak(<@)("0) i.3 3
>
> ┌┬┬───┐
>
> │00&+│01&+│2&+│
>
> ├┼┼───┤
>
> │3&+ │4&+ │5&+│
>
> ├┼┼───┤
>
> │6&+ │7&+ │8&+│
>
> └┴┴───┘
>
> ('x3 x4' =. ('X' Cloak(<@)("0) 3 4))
>
> x3
>
> 3&+
>
> x3 2
>
> 5
>
>
> using boxed verbs does require fishing them out, and an ar adverb (('ar' oa) 
> instead of (<@) makes them more "flexible".  Parser and display seem 
> resilient/solid to these shenanigans.
>
>
>
> On Tuesday, January 17, 2023 at 06:53:15 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> Verbs are first-class in J, in that they can be passed as ARs or by name
> and invoked in an explicit verb. Nothing more is needed.
>
> If a programmer is restricted to the tacit language (why? - I dunno)
> verbs cannot be first-class.  That seems to matter to some people.  I
> was trying to give them something.  I don't love the proposal either,
> but it seems pretty harmless.
>
> Any dangerous verb that attempts to return a non-noun is going to be
> crash-prone.  What would DV"0 (6 6)$'+' mean?  Its result is what type?
> what shape?
>
> I haven't followed the proposals closely.  All I know is that having a
> verb return a non-noun is going to create havoc inside JE.
>
> Henry Rich
>
> On 1/17/2023 6:42 PM, Elijah Stone wrote:
>> I don't love the proposal, as I think a conception of verbs as first
>> class should involve _less_ hackery with representations, not more.
>> But I don't feel that strongly either way.
>>
>> More fruitful, IMO, would be to work out how to add closures, as I
>> think there is a more urgent need for that (u./v. is a band-aid).
>> Perhaps taki

Re: [Jprogramming] Verbs returning verbs

2023-01-17 Thread 'Pascal Jasmin' via Programming
More ways to generate ARs doesn't hurt, but its not verbs returning non-nouns, 
or a path (n:) to obtain non-nouns from a verb phrase, so then the proposal is 
not meeting a major need.

repeating definitions,

eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : m'

isNoun_z_ =: (0 = 4!:0 ( :: 0:))@:< 

aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' '

Cloak=: aar(0:`)(,^:)

X=: 1 : 'm&+'

to answer your hypothetical DV question, it is actually possible to box verbs.

 'X' Cloak(<@)("0) i.3 3

┌┬┬───┐

│00&+│01&+│2&+│

├┼┼───┤

│3&+ │4&+ │5&+│

├┼┼───┤

│6&+ │7&+ │8&+│

└┴┴───┘

('x3 x4' =. ('X' Cloak(<@)("0) 3 4))

x3

3&+

x3 2

5


using boxed verbs does require fishing them out, and an ar adverb (('ar' oa) 
instead of (<@) makes them more "flexible".  Parser and display seem 
resilient/solid to these shenanigans.



On Tuesday, January 17, 2023 at 06:53:15 p.m. EST, Henry Rich 
 wrote: 





Verbs are first-class in J, in that they can be passed as ARs or by name 
and invoked in an explicit verb. Nothing more is needed.

If a programmer is restricted to the tacit language (why? - I dunno) 
verbs cannot be first-class.  That seems to matter to some people.  I 
was trying to give them something.  I don't love the proposal either, 
but it seems pretty harmless.

Any dangerous verb that attempts to return a non-noun is going to be 
crash-prone.  What would DV"0 (6 6)$'+' mean?  Its result is what type? 
what shape?

I haven't followed the proposals closely.  All I know is that having a 
verb return a non-noun is going to create havoc inside JE.

Henry Rich

On 1/17/2023 6:42 PM, Elijah Stone wrote:
> I don't love the proposal, as I think a conception of verbs as first 
> class should involve _less_ hackery with representations, not more.  
> But I don't feel that strongly either way.
>
> More fruitful, IMO, would be to work out how to add closures, as I 
> think there is a more urgent need for that (u./v. is a band-aid). 
> Perhaps taking inspiration from kernel (but skipping the mutation!).
>
> On Mon, 16 Jan 2023, Henry Rich wrote:
>
>> I have never understood the zeal for having verbs return verbs, but 
>> it must be real if some are willing to use dangerous backdoor hacks 
>> into JE to achieve it. ARs make it possible to pass verbs around, but 
>> executing them requires dropping into explicit code.  To remedy this, 
>> I offer a proposal, backward compatible with older J:
>>
>> 1. (". y) and Apply (x 128!:2 y) to be modified so that if the result 
>> of execution is not a noun, it is replaced by its AR (instead of '' 
>> as previously).
>>
>> 2. (". y) and Apply to be modified so that if y (for ".) or x (for 
>> Apply) is boxed, the sentence is executed as usual except that each 
>> box is converted using (box 5!:0) before being put onto the execution 
>> stack.
>>
>> The idea is that you can execute (". 
>> expr-producing-AR,exp-producing-AR,...) without having to get any 
>> modifiers involved.
>>
>> Sentence execution can produce ARs, and can take ARs created by verbs 
>> to represent verbs and modifiers.  That sounds pretty classy to me, 
>> but I don't know whether it's first-class.
>>
>> Henry Rich
>>
>>
>>
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm

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

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


Re: [Jprogramming] Closures; WAS: Verbs returning verbs

2023-01-17 Thread 'Pascal Jasmin' via Programming
Could this be called templating?


> (f%#) &:: ('f';+/`'') becomes +/%#.

what if f were already defined?  (usually substituted in verb phrases)

adverbs and conjunctions give this functionality.

I'm happy with the templating engine in this thread 
http://www.jsoftware.com/pipermail/programming/2020-September/056558.html 

I'm not sure what you meant by 



On Tuesday, January 17, 2023 at 07:01:15 p.m. EST, Elijah Stone 
 wrote: 





I suggest:

[x] u &:: (k;v;k;v...) y

Will evaluate u with bindings kvkv... (raveled) active.  Should work for both 
explicit and tacit.  Implementation is allowed to coalesce; e.g., u &:: (k;v) 
&:: (k;v) `'' may be rendered u &:: (k;v;k;v), deduplicated,  
Substitution also ok; eg (f%#) &:: ('f';+/`'') becomes +/%#.

I would like for verbs defined inside of explicit verbs to be implicitly 
closed; this is obviously a compat break, but.

On Tue, 17 Jan 2023, Elijah Stone wrote:

> I don't love the proposal, as I think a conception of verbs as first class 
> should involve _less_ hackery with representations, not more.  But I don't 
> feel that strongly either way.
>
> More fruitful, IMO, would be to work out how to add closures, as I think 
> there 
> is a more urgent need for that (u./v. is a band-aid).  Perhaps taking 
> inspiration from kernel (but skipping the mutation!).
>
> On Mon, 16 Jan 2023, Henry Rich wrote:
>
>> I have never understood the zeal for having verbs return verbs, but it 
>> must be real if some are willing to use dangerous backdoor hacks into JE 
>> to achieve it.  ARs make it possible to pass verbs around, but executing 
>> them requires dropping into explicit code.  To remedy this, I offer a 
>> proposal, backward compatible with older J:
>>
>> 1. (". y) and Apply (x 128!:2 y) to be modified so that if the result of 
>> execution is not a noun, it is replaced by its AR (instead of '' as 
>> previously).
>>
>> 2. (". y) and Apply to be modified so that if y (for ".) or x (for 
>> Apply) is boxed, the sentence is executed as usual except that each box 
>> is converted using (box 5!:0) before being put onto the execution stack.
>>
>> The idea is that you can execute (". 
>> expr-producing-AR,exp-producing-AR,...) without having to get any 
>> modifiers involved.
>>
>> Sentence execution can produce ARs, and can take ARs created by verbs to 
>> represent verbs and modifiers.  That sounds pretty classy to me, but I 
>> don't know whether it's first-class.
>>
>> Henry Rich
>>
>>
>>
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Verbs returning verbs

2023-01-17 Thread 'Pascal Jasmin' via Programming
are you saying that proposal is:

". ".'3&+'

3&+ NB. adverb?






On Tuesday, January 17, 2023 at 03:46:54 p.m. EST, Henry Rich 
 wrote: 





With the proposed enhancement to ". you don't /need/ to produce a 
modifier; you can execute the AR of the modifier.

Henry Rich

On 1/17/2023 3:12 PM, 'Pascal Jasmin' via Programming wrote:
> so an =: arnoun
>
> an =: 1 : '<@:((,''0'') ,&< ]) m' NB. atomic rep of noun as an adverb (right 
> arg)
>
> eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : m'
>
> aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' '
>
> aar provides the functionality of an, and ar, but when a name or modifier is 
> provided, it provides the ar of the name/modifier.
>
>
>> ". (arnoun value) , (". '+&')
> using the above functions and then building an adverb with it:
>
>   ((3 an) , ('+&' aar)) `:6  NB. or  ((3 aar) , ('+&' aar)) `:6
>
> +&3
>
>
> The moral of the example is that if we want to build up a noun/ar before 
> applying `:6 to it, we can already do so "legally".
>
> In the above example, do so without an extra ". ... though perhaps (". ars) 
> produces the same result as (ars)`:6, which has not been made fully clear.
>
> where (u 'adv' oa) is equivalent to (u n: adv),
>
> Cloak=: aar(0:`)(,^:)
>
> oa =: 1 :'u Cloak @:' NB. apply quoted adverb after result. Can produce 
> modifier from previous verb result as argument.
>
>    3 ((([ 'an' oa) , (] 'aar' oa))'`:6'oa) '+&'  NB. everything between () is 
>standalone function looks like a dyadic verb.
>
> +&3
>
> The missing J functionality is making a modifier (or non-noun) from "nouns" 
> and verbs.  It is not the inability to create ars.
>
>
>
> On Tuesday, January 17, 2023 at 12:13:21 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> Please confine this to my proposal - not including n: .
>
> It seems to me that if ". can produce any part of speech, and can be
> applied to ARs, it can do anything.  What is it missing?  For example,
>
> ". (arnoun value) , (". '+&')
>
> would produce the AR of (+) once you have written a suitable verb
> to take the AR of a noun.
>
> Henry Rich
>
> On 1/17/2023 11:59 AM, 'Pascal Jasmin' via Programming wrote:
>> The proposal for
>>
>> u n: ->  [x] u y  (and then u n: M => (([x] u y)M)  )
>>
>> would work with this so that
>>
>> ". n: `:6
>>
>> can consume "the output" though 2. suggests doing this.  Would:
>>
>> ". '+';'/'; '1 2 3'
>>
>> produce 3 boxes?  a linear expression?
>>
>>>     willing to use dangerous backdoor hacks into JE to achieve it
>> Dangerous seems harsh.  On the other side, verbs "needing to be" first class 
>> may not be necessary.  Verb phrases being able to produce non-nouns is the 
>> big missing capability.  Implies verb phrases can be different to verbs.
>>
>> n: is a very useful bridge for this distinction.  verbs can continue to be 
>> noun result only, and tested independently.  Adverbs/modifiers that take 
>> noun arguments can also be tested independently.  n: as a bridge can 
>> "document" that the overall verb phrase can produce a modifier.
>>
>>
>> I think n: can "complete J" with full transformability between verbs and 
>> modifiers.
>>
>> (n: C n:)  NB. allow 2 verb phrases (u and v)  to input to conjunction, 
>> potentially returning modifier.
>>
>> I like the proposals for ". and apply.  They are insufficient without n: due 
>> to not being able to be combined into a "larger" non-noun producing function.
>>
>>
>>
>> On Monday, January 16, 2023 at 08:35:59 p.m. EST, Henry Rich 
>>  wrote:
>>
>>
>>
>>
>>
>> I have never understood the zeal for having verbs return verbs, but it
>> must be real if some are willing to use dangerous backdoor hacks into JE
>> to achieve it.  ARs make it possible to pass verbs around, but executing
>> them requires dropping into explicit code.  To remedy this, I offer a
>> proposal, backward compatible with older J:
>>
>> 1. (". y) and Apply (x 128!:2 y) to be modified so that if the result of
>> execution is not a noun, it is replaced by its AR (instead of '' as
>> previously).
>>
>> 2. (". y) and Apply to be modified so that if y (for ".) or x (for
>> Apply) is boxed, the sentence is executed as usual except that e

Re: [Jprogramming] Verbs returning verbs

2023-01-17 Thread 'Pascal Jasmin' via Programming
so an =: arnoun

an =: 1 : '<@:((,''0'') ,&< ]) m' NB. atomic rep of noun as an adverb (right 
arg)

eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : m'

aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' '

aar provides the functionality of an, and ar, but when a name or modifier is 
provided, it provides the ar of the name/modifier.


> ". (arnoun value) , (". '+&')

using the above functions and then building an adverb with it:

 ((3 an) , ('+&' aar)) `:6  NB. or  ((3 aar) , ('+&' aar)) `:6

+&3


The moral of the example is that if we want to build up a noun/ar before 
applying `:6 to it, we can already do so "legally".

In the above example, do so without an extra ". ... though perhaps (". ars) 
produces the same result as (ars)`:6, which has not been made fully clear.

where (u 'adv' oa) is equivalent to (u n: adv),

Cloak=: aar(0:`)(,^:)

oa =: 1 :'u Cloak @:' NB. apply quoted adverb after result. Can produce 
modifier from previous verb result as argument.

  3 ((([ 'an' oa) , (] 'aar' oa))'`:6'oa) '+&'  NB. everything between () is 
standalone function looks like a dyadic verb.

+&3

The missing J functionality is making a modifier (or non-noun) from "nouns" and 
verbs.  It is not the inability to create ars.



On Tuesday, January 17, 2023 at 12:13:21 p.m. EST, Henry Rich 
 wrote: 





Please confine this to my proposal - not including n: .

It seems to me that if ". can produce any part of speech, and can be 
applied to ARs, it can do anything.  What is it missing?  For example,

". (arnoun value) , (". '+&')

would produce the AR of (+) once you have written a suitable verb 
to take the AR of a noun.

Henry Rich

On 1/17/2023 11:59 AM, 'Pascal Jasmin' via Programming wrote:
> The proposal for
>
> u n: ->  [x] u y  (and then u n: M => (([x] u y)M)  )
>
> would work with this so that
>
> ". n: `:6
>
> can consume "the output" though 2. suggests doing this.  Would:
>
> ". '+';'/'; '1 2 3'
>
> produce 3 boxes?  a linear expression?
>
>>   willing to use dangerous backdoor hacks into JE to achieve it
> Dangerous seems harsh.  On the other side, verbs "needing to be" first class 
> may not be necessary.  Verb phrases being able to produce non-nouns is the 
> big missing capability.  Implies verb phrases can be different to verbs.
>
> n: is a very useful bridge for this distinction.  verbs can continue to be 
> noun result only, and tested independently.  Adverbs/modifiers that take noun 
> arguments can also be tested independently.  n: as a bridge can "document" 
> that the overall verb phrase can produce a modifier.
>
>
> I think n: can "complete J" with full transformability between verbs and 
> modifiers.
>
> (n: C n:)  NB. allow 2 verb phrases (u and v)  to input to conjunction, 
> potentially returning modifier.
>
> I like the proposals for ". and apply.  They are insufficient without n: due 
> to not being able to be combined into a "larger" non-noun producing function.
>
>
>
> On Monday, January 16, 2023 at 08:35:59 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> I have never understood the zeal for having verbs return verbs, but it
> must be real if some are willing to use dangerous backdoor hacks into JE
> to achieve it.  ARs make it possible to pass verbs around, but executing
> them requires dropping into explicit code.  To remedy this, I offer a
> proposal, backward compatible with older J:
>
> 1. (". y) and Apply (x 128!:2 y) to be modified so that if the result of
> execution is not a noun, it is replaced by its AR (instead of '' as
> previously).
>
> 2. (". y) and Apply to be modified so that if y (for ".) or x (for
> Apply) is boxed, the sentence is executed as usual except that each box
> is converted using (box 5!:0) before being put onto the execution stack.
>
> The idea is that you can execute (".
> expr-producing-AR,exp-producing-AR,...) without having to get any
> modifiers involved.
>
> Sentence execution can produce ARs, and can take ARs created by verbs to
> represent verbs and modifiers.  That sounds pretty classy to me, but I
> don't know whether it's first-class.
>
> Henry Rich
>
>
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Verbs returning verbs

2023-01-17 Thread 'Pascal Jasmin' via Programming
The proposal for

u n: ->  [x] u y  (and then u n: M => (([x] u y)M)  )

would work with this so that

". n: `:6

can consume "the output" though 2. suggests doing this.  Would:

". '+';'/'; '1 2 3'

produce 3 boxes?  a linear expression?

> willing to use dangerous backdoor hacks into JE to achieve it

Dangerous seems harsh.  On the other side, verbs "needing to be" first class 
may not be necessary.  Verb phrases being able to produce non-nouns is the big 
missing capability.  Implies verb phrases can be different to verbs.

n: is a very useful bridge for this distinction.  verbs can continue to be noun 
result only, and tested independently.  Adverbs/modifiers that take noun 
arguments can also be tested independently.  n: as a bridge can "document" that 
the overall verb phrase can produce a modifier.


I think n: can "complete J" with full transformability between verbs and 
modifiers.

(n: C n:)  NB. allow 2 verb phrases (u and v)  to input to conjunction, 
potentially returning modifier.

I like the proposals for ". and apply.  They are insufficient without n: due to 
not being able to be combined into a "larger" non-noun producing function.



On Monday, January 16, 2023 at 08:35:59 p.m. EST, Henry Rich 
 wrote: 





I have never understood the zeal for having verbs return verbs, but it 
must be real if some are willing to use dangerous backdoor hacks into JE 
to achieve it.  ARs make it possible to pass verbs around, but executing 
them requires dropping into explicit code.  To remedy this, I offer a 
proposal, backward compatible with older J:

1. (". y) and Apply (x 128!:2 y) to be modified so that if the result of 
execution is not a noun, it is replaced by its AR (instead of '' as 
previously).

2. (". y) and Apply to be modified so that if y (for ".) or x (for 
Apply) is boxed, the sentence is executed as usual except that each box 
is converted using (box 5!:0) before being put onto the execution stack.

The idea is that you can execute (". 
expr-producing-AR,exp-producing-AR,...) without having to get any 
modifiers involved.

Sentence execution can produce ARs, and can take ARs created by verbs to 
represent verbs and modifiers.  That sounds pretty classy to me, but I 
don't know whether it's first-class.

Henry Rich



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


Re: [Jprogramming] best/any way to get verb result to m argument of modifier?

2023-01-14 Thread 'Pascal Jasmin' via Programming
(f g h) is a fork, where the last verb executed is g.  the result after g is 
executed is the same as the result after the fork is executed, as they are both 
the same moment.

A1 =: 1 : 'w@:u'
A2 =: 1 : 'w m'

will produce the same noun results in:  (where y is noun right argument, f g h 
w are verbs)  n: is the proposed adverb that makes this equivalence possible.

(f g h)A1 y

(f g A1 h) y

((f g h) y) A2

((f g h) n: A2) y

(f g n: A2 h)  y  NB. (n: A2) does not change "fork nature".



On Saturday, January 14, 2023 at 03:15:19 a.m. EST, Elijah Stone 
 wrote: 





(By coincidence, I mean that uACv is not the same as uCvA, in general.  Nor 
uA1A2 the same as uA2A1.  And f A g h is not the same as (f g h)A, either, 
e.g.)

On Sat, 14 Jan 2023, Elijah Stone wrote:

> I cannot make heads nor tails of anything you have said.  That f g(u@:) h is 
> the same as (f g h)(u@:) is true, but coincidence, and I don't see what it 
> has 
> to do with anything.
>
> On Sat, 14 Jan 2023, 'Pascal Jasmin' via Programming wrote:
>
>> Raul expressed by thinking,
>>
>> .> x (f g n:A h) y  would be same as (f g h) n: A -> (x ((x f y) g (x h
>> y)) y)A
>>
>> the logic is that g executes 3rd/last in (f g h), and f g(u@:) h) is same 
> as (f g h)(u@:)
>>
>> n: (A =: 1 : 'v m')is similar to (v@:) but applies to the result of the 
> verb phrase u (applied to x,y) instead of the verb phrase u
>>
>>
>>
>> On Friday, January 13, 2023 at 09:36:28 p.m. EST, Elijah Stone 
>  wrote: 
>>
>>
>>
>>
>>
>> Not quite (at least, not in my conception of it).  If it is to be useful in 
> a 
>> larger verb train, you have to work out where exactly x and y come from.  
> For 
>> instance, if we have x (f g n:A h) y, should we apply (x f y) ((x f y) g (x 
> h 
>> y))A (x h y)?  Or (x f y) (x g y)A (x h y)?  I say it should be chosen in 
> the 
>> same way as $: (which leads to the latter in this case).
>>
>> On Fri, 13 Jan 2023, Raul Miller wrote:
>>
>>> I find it difficult to reason about this n:
>>>
>>> My best guess is that n: is itself an adverb and that u n: A (where u
>>> is a verb and A is an adverb) would be handled by special code which
>>> behaves like
>>>   {{ (u y) A}} : {{(x u y) A}}
>>>
>>> Does that agree with your thinking?
>>>
>>> Thanks,
>>>
>>> -- 
>>> Raul
>>>
>>> On Fri, Jan 13, 2023 at 7:38 PM 'Pascal Jasmin' via Programming
>>>  wrote:
>>>>
>>>> To answer Raul,  I did not use r2m after all.  oa through the magic of 
> cloak allows 'Adverb' oa ('X' oa in example) where Adverb has a noun 
> parameter.
>>>>
>>>> >  I had: u n: A y is (u y) A y.  Whereas you have u r2m A y as simply (u 
> y) A.
>>>>
>>>> if [x] u n: A y produced the result of x u y as input to A, then that is 
> a legal way to get Adverb noun inputs from a verb phrase.  An adverb can 
> create modifiers is the main benefit, and necessity for the functionality.
>>>>
>>>>
>>>> I feel that u n: A y as (u y) A y would be for producing verbs and noun 
> results, and can be written as 1 : '(u y) A y' though that doesn't let you 
> produce a conjunction from A and return (C y).
>>>>
>>>> If there is ever an attack on the supreme majesty that is Cloak, I do 
> hope n: is implemented instead.
>>>>
>>>>
>>>> On Friday, January 13, 2023 at 05:39:30 p.m. EST, Elijah Stone 
>  wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Oh, my n: is a little less expressive than your r2m.  I had: u n: A y is 
> (u y)
>>>> A y.  Whereas you have u r2m A y as simply (u y) A.
>>>>
>>>> On Fri, 13 Jan 2023, Elijah Stone wrote:
>>>>
>>>> > I proposed your 'r2m' as a primitive n: (for 'now') a while ago, and 
> received
>>>> > a lukewarm response.  I don't think it can be implemented other than as 
> a
>>>> > primitive.  (And I still think it would be a good idea to have.)
>>>> >
>>>> > Your solution which quotes the modifier name works, but I find it
>>>> > distasteful.
>>>> > And it has some trouble with conjunctions; how do you disambiguate the
>>>> > following?
>>>> >
>>>> > (u r2m) C v
>>>> >
>>>> > u C (v r2m)
>>>> >
>>>> > (u r2m) C (v r2m)
>>>> >
>>>> > You can't,

Re: [Jprogramming] best/any way to get verb result to m argument of modifier?

2023-01-13 Thread 'Pascal Jasmin' via Programming
Raul expressed by thinking,

.> x (f g n:A h) y  would be same as (f g h) n: A -> (x ((x f y) g (x h
y)) y)A

the logic is that g executes 3rd/last in (f g h), and f g(u@:) h) is same as (f 
g h)(u@:)

n: (A =: 1 : 'v m')is similar to (v@:) but applies to the result of the verb 
phrase u (applied to x,y) instead of the verb phrase u



On Friday, January 13, 2023 at 09:36:28 p.m. EST, Elijah Stone 
 wrote: 





Not quite (at least, not in my conception of it).  If it is to be useful in a 
larger verb train, you have to work out where exactly x and y come from.  For 
instance, if we have x (f g n:A h) y, should we apply (x f y) ((x f y) g (x h 
y))A (x h y)?  Or (x f y) (x g y)A (x h y)?  I say it should be chosen in the 
same way as $: (which leads to the latter in this case).

On Fri, 13 Jan 2023, Raul Miller wrote:

> I find it difficult to reason about this n:
>
> My best guess is that n: is itself an adverb and that u n: A (where u
> is a verb and A is an adverb) would be handled by special code which
> behaves like
>  {{ (u y) A}} : {{(x u y) A}}
>
> Does that agree with your thinking?
>
> Thanks,
>
> -- 
> Raul
>
> On Fri, Jan 13, 2023 at 7:38 PM 'Pascal Jasmin' via Programming
>  wrote:
>>
>> To answer Raul,  I did not use r2m after all.  oa through the magic of cloak 
>> allows 'Adverb' oa ('X' oa in example) where Adverb has a noun parameter.
>>
>> >  I had: u n: A y is (u y) A y.  Whereas you have u r2m A y as simply (u y) 
>> >A.
>>
>> if [x] u n: A y produced the result of x u y as input to A, then that is a 
>> legal way to get Adverb noun inputs from a verb phrase.  An adverb can 
>> create modifiers is the main benefit, and necessity for the functionality.
>>
>>
>> I feel that u n: A y as (u y) A y would be for producing verbs and noun 
>> results, and can be written as 1 : '(u y) A y' though that doesn't let you 
>> produce a conjunction from A and return (C y).
>>
>> If there is ever an attack on the supreme majesty that is Cloak, I do hope 
>> n: is implemented instead.
>>
>>
>> On Friday, January 13, 2023 at 05:39:30 p.m. EST, Elijah Stone 
>>  wrote:
>>
>>
>>
>>
>>
>> Oh, my n: is a little less expressive than your r2m.  I had: u n: A y is (u 
>> y)
>> A y.  Whereas you have u r2m A y as simply (u y) A.
>>
>> On Fri, 13 Jan 2023, Elijah Stone wrote:
>>
>> > I proposed your 'r2m' as a primitive n: (for 'now') a while ago, and 
>> > received
>> > a lukewarm response.  I don't think it can be implemented other than as a
>> > primitive.  (And I still think it would be a good idea to have.)
>> >
>> > Your solution which quotes the modifier name works, but I find it
>> > distasteful.
>> > And it has some trouble with conjunctions; how do you disambiguate the
>> > following?
>> >
>> > (u r2m) C v
>> >
>> > u C (v r2m)
>> >
>> > (u r2m) C (v r2m)
>> >
>> > You can't, so you would need a separate form for each.
>> >
>> > On Fri, 13 Jan 2023, 'Pascal Jasmin' via Programming wrote:
>> >
>> >> X =: 1 : 'm&+'
>> >>
>> >>
>> >> What definition of r2m (result to m argument) below would allow X to see
>> > the result of + y (or x+y) as its m argument?
>> >>
>> >> + r2m X 3
>> >>
>> >> purpose would be for X to produce a modifier from application of "verb".
>> > Requirement is only that y argument (3 above) is outside any verb phrase.
>> >>
>> >> Jose/Dan's Cloak magic? turn result into atomic or linear representation?
>> >> --
>> >> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] best/any way to get verb result to m argument of modifier?

2023-01-13 Thread 'Pascal Jasmin' via Programming
To answer Raul,  I did not use r2m after all.  oa through the magic of cloak 
allows 'Adverb' oa ('X' oa in example) where Adverb has a noun parameter.

>  I had: u n: A y is (u y) A y.  Whereas you have u r2m A y as simply (u y) A.

if [x] u n: A y produced the result of x u y as input to A, then that is a 
legal way to get Adverb noun inputs from a verb phrase.  An adverb can create 
modifiers is the main benefit, and necessity for the functionality.  


I feel that u n: A y as (u y) A y would be for producing verbs and noun 
results, and can be written as 1 : '(u y) A y' though that doesn't let you 
produce a conjunction from A and return (C y).  

If there is ever an attack on the supreme majesty that is Cloak, I do hope n: 
is implemented instead.


On Friday, January 13, 2023 at 05:39:30 p.m. EST, Elijah Stone 
 wrote: 





Oh, my n: is a little less expressive than your r2m.  I had: u n: A y is (u y) 
A y.  Whereas you have u r2m A y as simply (u y) A.

On Fri, 13 Jan 2023, Elijah Stone wrote:

> I proposed your 'r2m' as a primitive n: (for 'now') a while ago, and received 
> a lukewarm response.  I don't think it can be implemented other than as a 
> primitive.  (And I still think it would be a good idea to have.)
>
> Your solution which quotes the modifier name works, but I find it 
> distasteful. 
> And it has some trouble with conjunctions; how do you disambiguate the 
> following?
>
> (u r2m) C v
>
> u C (v r2m)
>
> (u r2m) C (v r2m)
>
> You can't, so you would need a separate form for each.
>
> On Fri, 13 Jan 2023, 'Pascal Jasmin' via Programming wrote:
>
>> X =: 1 : 'm&+'
>>
>>
>> What definition of r2m (result to m argument) below would allow X to see 
> the result of + y (or x+y) as its m argument?
>>
>> + r2m X 3
>>
>> purpose would be for X to produce a modifier from application of "verb".  
> Requirement is only that y argument (3 above) is outside any verb phrase.
>>
>> Jose/Dan's Cloak magic? turn result into atomic or linear representation?
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] (A n) new train. was: more fun with parallelism

2023-01-13 Thread 'Pascal Jasmin' via Programming
n permits natural 
ambivalence.CONTEXT: <;._1 ' unique uniquebyitem sortedD sortedbyitemD'

0 _1 _2 _3 _4


choosing an adverb result

 2 minus nATTRIB 2 iotaA 5  NB. minus inverts sorted and sortedbyitem

(P(<;._1 ' unique uniquebyitem sortedD sortedbyitemD')) ATTRIB (0 _1 _2 _3 _4)

2 minus@:minus nATTRIB 2 iotaA 5  NB. minus@minus reverts to sorted

(P(<;._1 ' unique uniquebyitem sorted sortedbyitem')) ATTRIB (0 1 2 3 4)

(minus 2 minus 2 iotaA 5)nATTRIB1 NB. use core adverb (nATTRIB1 ) to transform 
linear code result to "adverb decoration of noun".

(P(<;._1 ' unique uniquebyitem sorted sortedbyitem')) ATTRIB (0 1 2 3 4)

Things I learned from doing this:

It is possible to step into a manageable world where cats eat dogs, and nouns 
can be turned into adverbs.

(A APPLY n) replaces the need for (A n) except that perhaps magic behind (A n) 
could make dyadic u more convenient.

A guard adverb to a noun can present promises on the noun.  u@/:~ or  u@~.  are 
ways to ensure the same, but if data is already in a sorted/unique state, those 
functions "get free guards" when operation is free.  Performance impact when 
not needed/useful is minimal. 


On Wednesday, January 11, 2023 at 05:28:46 p.m. EST, Raul Miller 
 wrote: 





On Wed, Jan 11, 2023 at 1:15 PM 'Pascal Jasmin' via Programming
 wrote:
> > I don't think there's a strong need to allow users to set flags on nouns.
> It's rather a dangerous thing to do, and you could instead just run the nouns
> through /:~ or ~.
>
> marked nouns would allow those functions to return identity (while retaining 
> marking/annotation of sorted/unique)

Only in contexts where operations which retain those marks are the
only operations which have been performed since a seed noun was
marked.

And every operation that supports those marks becomes more complex
(and potentially slower, dealing with cases which retain vs. lose the
marks).

Meanwhile, conceptually, what we're doing here is eliminating code
that the programmer could have avoided or which the parser could have
treated differently.

Or: there are going to be situations where this is going to be a win
but there's also situations where this is going to be a loss. How do
we distinguish between these cases in a statistically significant
fashion?

Thanks,

-- 
Raul

>
> i. generates a sorted/unique list.
>
> functions marked as monotonic would preserve unique and sorted attributes.
>
> 7 (42)(]: i.~ *) i.8
>
> 6  NB. since * is monotonic, if y is sorted unique, then it may be 
> appropriate to "binary search/try" elements of y out of order applying * to 
> just the guesses.
>
> where x is a unique list then (2 3 +"0 1 i.5) has attribute "unique/sorted 
> ByRow"
>
> which makes f"1 see unique and sorted.  "Unique/sorted by column" would let 
> f("1)@|: see unique/sorted data.
>
> In my dictionary implementation,  https://github.com/Pascal-J/kv
>
> marking the whole structure as dictionary or raggedArray (unreleased 
> implementation based on kv) might allow { } to natively understand dictionary.
>
> More importantly, the impementation treats updates as appends by default.  
> get function uses i: to still access kv as if it were unique  keyed.  
> Advantage is faster appends, permitting undo update operation, or permitting 
> multiple key,value pairs with the same key, allowing one to many relations 
> for example, or using J's key function on data structure.  The key/value 
> lists are also order preserved if that is relevant to context used.
>
> There are operations to uniquify and sort the dictionary (by key).  The usual 
> J dataflow is to bulk append/manipulate data, then set it in access mode 
> only.  kv's design is to separate these steps.
> Some of the example KVs model attributes and DATA as special key containing 
> value.
>
> Pyxs are probably better boxed than attributed, but might have some 
> convenience with some extra attributes.  Perhaps using them for hints as to 
> when they might be complete, perhaps with code running inside a thread that 
> updates % complete.  OTOH, using pyx attributes would generally involve a 
> system that can track attributes in its own data structures.  Sorry if this 
> is not useful.
>
>
>
>
>
> On Tuesday, January 10, 2023 at 09:48:17 p.m. EST, Elijah Stone 
>  wrote:
>
>
>
>
>
> I originally wanted just one adverb to indicate associativity.  But then other
> things just started piling up.  As yet, we have:
>
> - associativity
>
> - commutativity
>
> - identity
>
> - fixedpoint
>
> Commutativity enables a bit more flexibility wrt parallelism, and might have
> other uses (forget); identity plugs a long-standing hole, which is that +/''
> is 0, but user-defined u/'' is an err

Re: [Jprogramming] best/any way to get verb result to m argument of modifier?

2023-01-13 Thread 'Pascal Jasmin' via Programming
Cloak strikes again,

isNoun_z_ =: (0 = 4!:0 ( :: 0:))@:< 
eval_z_ =: 1 : 'if. 2 ~: 3!:0 m do. m else. a: 1 : m end.' NB.1 : ' a: 1 : m'
aar =: 1 : 'if. isNoun ''u'' do. q =. m eval else. q =. u end. 5!:1 < ''q'' '
Cloak=: aar(0:`)(,^:)
oa =: 1 :'u Cloak @:' NB. apply quoted adverb after result. Can produce modifier


    + 'X' oa 32

32&+

2 (+ 'X' oa) 32

34&+

2 + ('X' oa) 32

34&+





On Friday, January 13, 2023 at 11:19:49 a.m. EST, 'Pascal Jasmin' via 
Programming  wrote: 





X =: 1 : 'm&+'


What definition of r2m (result to m argument) below would allow X to see the 
result of + y (or x+y) as its m argument?

+ r2m X 3

purpose would be for X to produce a modifier from application of "verb".  
Requirement is only that y argument (3 above) is outside any verb phrase.

Jose/Dan's Cloak magic? turn result into atomic or linear representation?
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


[Jprogramming] best/any way to get verb result to m argument of modifier?

2023-01-13 Thread 'Pascal Jasmin' via Programming
X =: 1 : 'm&+'


What definition of r2m (result to m argument) below would allow X to see the 
result of + y (or x+y) as its m argument?

+ r2m X 3

purpose would be for X to produce a modifier from application of "verb".  
Requirement is only that y argument (3 above) is outside any verb phrase.

Jose/Dan's Cloak magic? turn result into atomic or linear representation?
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] (A n) new train. was: more fun with parallelism

2023-01-11 Thread 'Pascal Jasmin' via Programming


> I don't think there's a strong need to allow users to set flags on nouns.
It's rather a dangerous thing to do, and you could instead just run the nouns
through /:~ or ~.

marked nouns would allow those functions to return identity (while retaining 
marking/annotation of sorted/unique)

i. generates a sorted/unique list.

functions marked as monotonic would preserve unique and sorted attributes.

7 (42)(]: i.~ *) i.8

6  NB. since * is monotonic, if y is sorted unique, then it may be appropriate 
to "binary search/try" elements of y out of order applying * to just the 
guesses.

where x is a unique list then (2 3 +"0 1 i.5) has attribute "unique/sorted 
ByRow"

which makes f"1 see unique and sorted.  "Unique/sorted by column" would let 
f("1)@|: see unique/sorted data.

In my dictionary implementation,  https://github.com/Pascal-J/kv

marking the whole structure as dictionary or raggedArray (unreleased 
implementation based on kv) might allow { } to natively understand dictionary.

More importantly, the impementation treats updates as appends by default.  get 
function uses i: to still access kv as if it were unique  keyed.  Advantage is 
faster appends, permitting undo update operation, or permitting multiple 
key,value pairs with the same key, allowing one to many relations for example, 
or using J's key function on data structure.  The key/value lists are also 
order preserved if that is relevant to context used.

There are operations to uniquify and sort the dictionary (by key).  The usual J 
dataflow is to bulk append/manipulate data, then set it in access mode only.  
kv's design is to separate these steps. 
Some of the example KVs model attributes and DATA as special key containing 
value.

Pyxs are probably better boxed than attributed, but might have some convenience 
with some extra attributes.  Perhaps using them for hints as to when they might 
be complete, perhaps with code running inside a thread that updates % complete. 
 OTOH, using pyx attributes would generally involve a system that can track 
attributes in its own data structures.  Sorry if this is not useful.





On Tuesday, January 10, 2023 at 09:48:17 p.m. EST, Elijah Stone 
 wrote: 





I originally wanted just one adverb to indicate associativity.  But then other 
things just started piling up.  As yet, we have:

- associativity

- commutativity

- identity

- fixedpoint

Commutativity enables a bit more flexibility wrt parallelism, and might have 
other uses (forget); identity plugs a long-standing hole, which is that +/'' 
is 0, but user-defined u/'' is an error, and it also slightly simplifies some 
parallel pipelines; fixedpoint enables early-out in u/; all of these are 
useful and desirable.  There could be more yet.

I don't love naming them with strings, but I don't think names like ASSOC. are 
better.  I would like to have one-character abbreviations for all or most, 
which is hopefully more palatable.

For unset, I imagine saying u A: 'associative' is sugar for u A: 
('associative';1); hence, you could say u A:('associative';1) 
A:('associative';0).  That doesn't work for identity/fixedpoint; I guess you 
could add a layer of boxing, but that seems annoying.  I don't think it's very 
important, but could surely be worked out.  (I almost hesitate to say 
it--perhaps use _. to unset a noun attribute?)

I don't think there's a strong need to allow users to set flags on nouns. 
It's rather a dangerous thing to do, and you could instead just run the nouns 
through /:~ or ~. (in the case of sorted/unique); the thing about functions is 
that rice's theorem is always waiting around the corner to screw you over the 
moment you try to do anything useful.

On Wed, 11 Jan 2023, Hauke Rehr wrote:

> Very interesting indeed, all of this thread.
>
> I think annotation both of nouns and verbs would be useful.
> Do we also need a way of de-annotation?
> Probably not but I haven’t thought it through.
>
> I don’t like the literal approach. I’d rather have J know about
> constants ASSOC. and SORTED. and the like to be used for that
> purpose (better response to misspellings and imo cleaner approach).
>
> What grammar should the query and set (and maybe unset) primitives have?
> Hard to tell which approach would work out better.
>
> But I would favor such primitives – building corresponding
> conjunctions should be fairly easy and might even be done
> for all currently known decorations in a script distributed
> but not loaded by default.
> But maybe I missed a point why that new train actually
> improves the situation here.
>
> Hauke
>
>
> Am 10.01.23 um 19:10 schrieb 'Pascal Jasmin' via Programming:
>>  There is after all a Conjunction approach that permits ambivalent u verb, 
>> and so for attributes that current native J code could leverage, it would 
>> be possible to have full functionality of (A 

Re: [Jprogramming] more fun with parallelism

2023-01-10 Thread 'Pascal Jasmin' via Programming
 u/ P. 'Associative'  and P:
would let you/us describe/annotate verbs and invoke associative optimizations 
on it.
The Associative adverb or attribute applies only to functions (doesn't make 
sense for data)
It also applies to only insert operations, and then as an adverb it could all 
be built in.  Following defintion
Associative =: (P. 'Associative')/  NB. insert is built in.  So +Associative -: 
+/
It would be up to "/" internals to see if u is either one of the native verbs 
it knows to be associative, or a user decorated u (as determined by P:), as the 
above adverb provides.
Decorating data/nouns could be possible
0 1 2 3 4 P. 'Sorted Unique'
P. P: would be interfaces to hidden dictionaries, that rely on hash values of 
data to identify keys/data.  So, once 0 1 2 3 4 was declared sorted/unique, 
that exact data string would always be unique.
The Sorted as an adverb and (Sorted n) A n train has a few advantages.  First, 
both u P. n and m P. n would return u/m.  So,
Sorted =: {{u P. 'Sorted'}}  NB. or just (P. 'Sorted')
The "brains" for what to do with Sorted data would be in i.e.E. family, and 
user functions that query P: 
using P. 'Attribute' on the verb would result in faster likely hashing speed 
then potentially large data.  (A n) never applies A to n (only uA n), even 
though it associates A (Sorted) and n (data) together.
 Another implementation would be that attributes apply to context (of y) only.
data =: ((P. 'Sorted') (P. 'Unique') 1 2 3 4  NB. ((AA) n) 
when u applied to data, context of u from queries to P: will return true for 
Sorted and Unique attributes.  Because u P. 'attribute' returns u, when u y 
eventually runs, the context (queried by P:) is available.
(A n) would allow no memory baggage from "data attributes".
However, implementation  u (A n) -> (uA n) : (x uA n)  is probably hard.



On Tuesday, January 10, 2023 at 03:45:06 p.m. EST, Jan-Pieter Jacobs 
 wrote:  
 
 Intuitively, to me it would make sense to have a conjunction, e.g. P., to
set properties, provided as literal characters, to a verb (or, if it would
become desirable for other use cases, for nouns as well), and a
corresponding adverb (in line with b.) to query them. I bet there are other
properties one could usefully pass to the JE other than only associativity.
If we have to come up with a dedicated adv/conj for each of them, I think
it's not very sustainable.
Having a query adverb or conjunction (e.g. P:), the user could also use the
queried value in conditional code if needed (e.g. u P: '' returns all
attributes as literal string, u P:'a' could return a boolean whether u is
associative or not).
I didn't take a good look at how nicely such a proposal would play with
modifier trains though.

Jan-Pieter

Op di 10 jan. 2023 om 16:35 schreef 'Pascal Jasmin' via Programming <
programm...@jsoftware.com>:

>  > S.
> I was going to suggest some foreign equivalent to S.  But this approach is
> sufficient.  A: (for (A)ssociative declaration) would be another
> candidate.  if A: (or a foreign adverb) were used for this.  u S. could be
> a declaration/hint that the y argument to u is in sorted order.
> plus =: + A: NB. or + S.
> becomes a "decorated verb" without creating an "attribute system" that
> would be completely new to J.
> One way to add attributes to data would be a new train:
> A n  : adverb where: u (A n) -> (uA n) : (x uA n)
> Though this can already be done with a conjunction, so the case for a new
> train seems dubious.  Except that both a conjunction and this new adverb
> train "eat y" argument to produce a noun, which is somewhat unusual, and
> then that "specialness" can perhaps justify a new train.  Another issue
> with conjunction approach is that if u is forced monadic only, then x
> loses the ability to apply dyadic rank to u.  If u is forced to be dyadic
> only, then a conjunction must be a "triple modifier" (return an adverb),
> where say [: would apply uCn, and a noun would apply m uC n (where m is
> final 3rd parameter).
> (A n) would decorate nouns intuitively such that data =: (A data) when
> used as y argument allows "transparent use" where
> u (A n) -: (uA) y  x (uA) y -: x u (A n)
>
> even when (A n) is decorating/attributing a noun, it is saying "apply all
> verbs to this noun as uA" where A would typically be a giant switch/case.
> statement that chooses among implementations of u.  Even if Associative
> "decorator" applies to verbs rather than data, Unique, Sorted would
> typically attribute data.  But "user" decorations like Dictionary,
> RaggedArray would define the structure of a noun such that built in J
> operators can be overriden to "understand the data structure".
> DataIsChunkable can be an adverb that splits the data into chunks and
> app

Re: [Jprogramming] (A n) new train. was: more fun with parallelism

2023-01-10 Thread 'Pascal Jasmin' via Programming
 Elijah brought up the possibility of decorating verbs
Associative adverb would be a declaration that 1 u 2 u 3 is the same result as 
(1 u 2) u 3.  and then u Associative/ might be parallel optimized in its 
implementation, in addition to documenting the programmer's assumptions.
for (A n)
A Sorted adverb in this case would decorate the data that is asserted to be 
sorted by the declaration and (Sorted (sort n)) would ensure it.  (i.~ Sorted) 
would allow choosing an implementation of i.~ that assumes data is sorted, 
which I presume can be faster.  (i.~ Unique Sorted) would invoke multiple 
assumptions of the data, that can also be "bound" to the data instead if (A n) 
or (A A n) -: ((AA)n) exist as trains. 

On Tuesday, January 10, 2023 at 01:20:59 p.m. EST, Raul Miller 
 wrote:  
 
 What would this Associative adverb do?

Also, can this approach be made to usefully invoke (+/!.0) ?

Thanks,

-- 
Raul

On Tue, Jan 10, 2023 at 1:12 PM 'Pascal Jasmin' via Programming
 wrote:
>
>  There is after all a Conjunction approach that permits ambivalent u verb, 
>and so for attributes that current native J code could leverage, it would be 
>possible to have full functionality of (A n) suggestion.
> Dn =: 2 : 'v u ]'  NB. dyadic with x as n or monadic with [: as v
>    +/"1 0 (Dn 2 3) i.5  NB. or natural xy order: 2 3 (+/"1 0 Dn ) i.5
> 2 3
>
> 3 4
>
> 4 5
>
> 5 6
>
> 6 7
>
>  +/"0 1 Dn 2 3 ] i.5
> 2 3 4 5 6
>
> 3 4 5 6 7
>
>
>
>
> +/"0 1 Dn [: i.5
>
> 10
>
> this would let you/us decorate a verb as:  (where Associative is an adverb)
> (Dn Associative)((Dn Associative) [:) NB. Monad only u  Or ((Dn 
> [:)Associative) or just Associative((u Dn) Associative) NB. ambivalent fixed 
> u, but monad needs [: in x position.
> Decorating a noun requires a conjunction, but is still possible:  (where 
> Sorted is a conjunction)
> (Sorted data) NB. adverb instead noun that was data.
> where Sorted that does nothing (to modify/choose implementation of u) can be:
> Sorted =: APPLY =: 2 : ' u n'
>
> u Sorted data -: u (Sorted data) NB. for monad u
>
>  + Sorted 3
>
> 3
>
> (u Dn) (Sorted Data)  NB. dyad u
>
>  2 (+ Dn) (Sorted 3)
>
> 5
>
>
> 2 (i.~ Dn) (Sorted (i.5))
> 2
>
> 2 (i.~ Dn) Sorted (i.5)
>
> 2
>
>
>  findfirstsorted =: (i.~ Dn) Sorted ]: NB. ACA
>
>
> 2 findfirstsorted (i.5)  NB. presumed sorted without "data attribute"
>
> 2
>
> findfirstAttributeSorted =: (i.~ Dn)  NB. real function might optimize 
> implementation of i. but delegation requires lookahead not part of 
> interpreter.
>
>
> 3 findfirstAttributeSorted (Sorted (i.5))
>
> 3
>
> The case for (A n) is that it would designate a special decorated noun that 
> because it is special can be peeked inside of (the adverb) to determine the 
> decoration, and then when a verb is applied, the proper verb implementation 
> suited to the decoration can be chosen.  It is also a bit more flexible to 
> implement decorations either as (u A) or (A n) for any A.
> on a different note, reusing D. and D: could be
> D. =: 2 : 'v u ]'  NB. Dn above, but v is any ambivalent verb or [: . u~ D. v 
>  is dyadic compose with y as 2nd x: ie. becomes ] u v. Also monadic hook.D:=: 
> 2 : '[ u v'  NB. dyadic compose with repeated x, or monadic hook
>
>    On Tuesday, January 10, 2023 at 10:35:16 a.m. EST, 'Pascal Jasmin' via 
>Programming  wrote:
>
>  > S.
> I was going to suggest some foreign equivalent to S.  But this approach is 
> sufficient.  A: (for (A)ssociative declaration) would be another candidate.  
> if A: (or a foreign adverb) were used for this.  u S. could be a 
> declaration/hint that the y argument to u is in sorted order.
> plus =: + A: NB. or + S.
> becomes a "decorated verb" without creating an "attribute system" that would 
> be completely new to J.
> One way to add attributes to data would be a new train:
> A n  : adverb where: u (A n) -> (uA n) : (x uA n)
> Though this can already be done with a conjunction, so the case for a new 
> train seems dubious.  Except that both a conjunction and this new adverb 
> train "eat y" argument to produce a noun, which is somewhat unusual, and then 
> that "specialness" can perhaps justify a new train.  Another issue with 
> conjunction approach is that if u is forced monadic only, then x loses the 
> ability to apply dyadic rank to u.  If u is forced to be dyadic only, then a 
> conjunction must be a "triple modifier" (return an adverb), where say [: 
> would apply uCn, and a noun would apply m uC n (where m is final 3rd 
> parameter).
> (A n) would decorate nouns intuitively such that data =: (A data) when

Re: [Jprogramming] (A n) new train. was: more fun with parallelism

2023-01-10 Thread 'Pascal Jasmin' via Programming
 There is after all a Conjunction approach that permits ambivalent u verb, and 
so for attributes that current native J code could leverage, it would be 
possible to have full functionality of (A n) suggestion.
Dn =: 2 : 'v u ]'  NB. dyadic with x as n or monadic with [: as v
   +/"1 0 (Dn 2 3) i.5  NB. or natural xy order: 2 3 (+/"1 0 Dn ) i.5
2 3

3 4

4 5

5 6

6 7

 +/"0 1 Dn 2 3 ] i.5
2 3 4 5 6

3 4 5 6 7




+/"0 1 Dn [: i.5

10

this would let you/us decorate a verb as:  (where Associative is an adverb)
(Dn Associative)((Dn Associative) [:) NB. Monad only u  Or ((Dn [:)Associative) 
or just Associative((u Dn) Associative) NB. ambivalent fixed u, but monad needs 
[: in x position.
Decorating a noun requires a conjunction, but is still possible:  (where Sorted 
is a conjunction)
(Sorted data) NB. adverb instead noun that was data.
where Sorted that does nothing (to modify/choose implementation of u) can be:
Sorted =: APPLY =: 2 : ' u n'

u Sorted data -: u (Sorted data) NB. for monad u

 + Sorted 3

3

(u Dn) (Sorted Data)  NB. dyad u

  2 (+ Dn) (Sorted 3)

5


2 (i.~ Dn) (Sorted (i.5))
2

2 (i.~ Dn) Sorted (i.5)

2


 findfirstsorted =: (i.~ Dn) Sorted ]: NB. ACA


2 findfirstsorted (i.5)  NB. presumed sorted without "data attribute"

2

findfirstAttributeSorted =: (i.~ Dn)  NB. real function might optimize 
implementation of i. but delegation requires lookahead not part of interpreter.


3 findfirstAttributeSorted (Sorted (i.5))

3

The case for (A n) is that it would designate a special decorated noun that 
because it is special can be peeked inside of (the adverb) to determine the 
decoration, and then when a verb is applied, the proper verb implementation 
suited to the decoration can be chosen.  It is also a bit more flexible to 
implement decorations either as (u A) or (A n) for any A.
on a different note, reusing D. and D: could be
D. =: 2 : 'v u ]'  NB. Dn above, but v is any ambivalent verb or [: . u~ D. v  
is dyadic compose with y as 2nd x: ie. becomes ] u v. Also monadic hook.D:=: 2 
: '[ u v'  NB. dyadic compose with repeated x, or monadic hook

On Tuesday, January 10, 2023 at 10:35:16 a.m. EST, 'Pascal Jasmin' via 
Programming  wrote:  
 
 > S.
I was going to suggest some foreign equivalent to S.  But this approach is 
sufficient.  A: (for (A)ssociative declaration) would be another candidate.  if 
A: (or a foreign adverb) were used for this.  u S. could be a declaration/hint 
that the y argument to u is in sorted order.
plus =: + A: NB. or + S.
becomes a "decorated verb" without creating an "attribute system" that would be 
completely new to J.
One way to add attributes to data would be a new train:
A n  : adverb where: u (A n) -> (uA n) : (x uA n)
Though this can already be done with a conjunction, so the case for a new train 
seems dubious.  Except that both a conjunction and this new adverb train "eat 
y" argument to produce a noun, which is somewhat unusual, and then that 
"specialness" can perhaps justify a new train.  Another issue with conjunction 
approach is that if u is forced monadic only, then x loses the ability to 
apply dyadic rank to u.  If u is forced to be dyadic only, then a conjunction 
must be a "triple modifier" (return an adverb), where say [: would apply uCn, 
and a noun would apply m uC n (where m is final 3rd parameter).
(A n) would decorate nouns intuitively such that data =: (A data) when used as 
y argument allows "transparent use" where
u (A n) -: (uA) y   x (uA) y -: x u (A n)

even when (A n) is decorating/attributing a noun, it is saying "apply all verbs 
to this noun as uA" where A would typically be a giant switch/case. statement 
that chooses among implementations of u.  Even if Associative "decorator" 
applies to verbs rather than data, Unique, Sorted would typically attribute 
data.  But "user" decorations like Dictionary, RaggedArray would define the 
structure of a noun such that built in J operators can be overriden to 
"understand the data structure".  DataIsChunkable can be an adverb that splits 
the data into chunks and applies u in threads on each chunk, then optionally 
unpixes them, though that is more likely to be a verb annotation than data 
annotation.
One complication, or possibly elegance, of (A n) is how to handle:
(A n) A
where u (A n) -> (uA n) : (x uA n), is treating n as a y argument to uA
(A1 n) A2 would be an adverb train that defers computation until u is provided 
instead of treating (A1 n) as the m argument to A2.  example:
newdata =: [x] u ((Sorted data) ApplySortedIfSorted)
would make newdata either a simple noun or (Sorted newdata)  "decorated noun". 
ApplySortedIfSorted becomes an adverb applied after u (Sorted data) is applied 
and produces a noun result.  You can even define the noun data interchangeably 
with the adverb:
((data Sorted) ApplySortedIfSorted)
and use 

Re: [Jprogramming] more fun with parallelism

2023-01-10 Thread 'Pascal Jasmin' via Programming
 > S.
I was going to suggest some foreign equivalent to S.  But this approach is 
sufficient.  A: (for (A)ssociative declaration) would be another candidate.  if 
A: (or a foreign adverb) were used for this.  u S. could be a declaration/hint 
that the y argument to u is in sorted order.
plus =: + A: NB. or + S.
becomes a "decorated verb" without creating an "attribute system" that would be 
completely new to J.
One way to add attributes to data would be a new train:
A n  : adverb where: u (A n) -> (uA n) : (x uA n)
Though this can already be done with a conjunction, so the case for a new train 
seems dubious.  Except that both a conjunction and this new adverb train "eat 
y" argument to produce a noun, which is somewhat unusual, and then that 
"specialness" can perhaps justify a new train.  Another issue with conjunction 
approach is that if u is forced monadic only, then x loses the ability to 
apply dyadic rank to u.  If u is forced to be dyadic only, then a conjunction 
must be a "triple modifier" (return an adverb), where say [: would apply uCn, 
and a noun would apply m uC n (where m is final 3rd parameter).
(A n) would decorate nouns intuitively such that data =: (A data) when used as 
y argument allows "transparent use" where
u (A n) -: (uA) y   x (uA) y -: x u (A n)

even when (A n) is decorating/attributing a noun, it is saying "apply all verbs 
to this noun as uA" where A would typically be a giant switch/case. statement 
that chooses among implementations of u.  Even if Associative "decorator" 
applies to verbs rather than data, Unique, Sorted would typically attribute 
data.  But "user" decorations like Dictionary, RaggedArray would define the 
structure of a noun such that built in J operators can be overriden to 
"understand the data structure".  DataIsChunkable can be an adverb that splits 
the data into chunks and applies u in threads on each chunk, then optionally 
unpixes them, though that is more likely to be a verb annotation than data 
annotation.
One complication, or possibly elegance, of (A n) is how to handle:
(A n) A
where u (A n) -> (uA n) : (x uA n), is treating n as a y argument to uA
(A1 n) A2 would be an adverb train that defers computation until u is provided 
instead of treating (A1 n) as the m argument to A2.  example:
newdata =: [x] u ((Sorted data) ApplySortedIfSorted)
would make newdata either a simple noun or (Sorted newdata)  "decorated noun". 
ApplySortedIfSorted becomes an adverb applied after u (Sorted data) is applied 
and produces a noun result.  You can even define the noun data interchangeably 
with the adverb:
((data Sorted) ApplySortedIfSorted)
and use it interchangeably with verbs that would treat data as their y argument.

On Tuesday, January 10, 2023 at 12:10:17 a.m. EST, Elijah Stone 
 wrote:  
 
 My preference is to allow the user to specify what transformations they would 
like to permit the implementation to perform in what contexts, as recommended 
by ieee 754 (sec 10.4).  Perhaps an adverb S., such that [x] u S. y applies u 
with strict fp semantics.  Or perhaps a function attribute, specified in 
similar manner to associativity (howsoever that is specified).

On Mon, 9 Jan 2023, Marshall Lochbaum wrote:

> Well, true, I'm not in favor of rearranging +/ either. The dangers of
> floating point don't include nondeterminism, unless you make them.
>
> However, I also think matrix products have it worse. Numbers with widely
> varying exponents are a bit of an edge case. But when you're multiplying
> a few large matrices together they can show up naturally, so I expect
> it's not so rare to have a product that's numerically stable in one
> direction and not in the other.
>
> Marshall
>
> On Mon, Jan 09, 2023 at 05:52:34PM -0600, Omar Antolín Camarena wrote:
>> But that's just normal floating non-associativity. It happens even for 
>> addition of "integers":
>>
>>    1 + (_1e19 + 1e19)
>> 1
>>    (1 + _1e19) + 1e19
>> 0
>> 
>> People using floating point are probably aware of the dangers or at least 
>> should be.
>> 
>> -- 
>> Omar
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] tine

2023-01-05 Thread 'Pascal Jasmin' via Programming
 missing line break, sorry
 M =: @] 
v2c =: 1 : '[. u ].'

tine =: 1 : ' (M~) (u v2c) M '

On Thursday, January 5, 2023 at 07:32:34 p.m. EST, 'Pascal Jasmin' via 
Programming  wrote:  
 
   M =: @]v2c =: 1 : '[. u ].'

tine =: 1 : ' (M~) (u v2c) M '
there was a recent change to allow gerund argument to &.
& and &: could allow gerund v such that w&(u`v)  is (u@[ w v@]).  But tine as 
written is easier to use (only one function.  no parenthesizing gerund 
arguments).



    On Thursday, January 5, 2023 at 06:03:33 p.m. EST, Raul Miller 
 wrote:  
 
 Sometimes it seems like it would be nice to have a variation on fork
where instead of (f g h) we get *f@[ g h@])

And, of course, we can do that manually. (Also, I forget the contexts
where I have wanted to use this. Maybe I'll remember later. I also
have a vague memory of someone else asking for something like this.)

Anyways, it's fairly straightforward to implement, though perhaps a
bit tough to read (since mostly we don't mess with this kind of
thing):

tine=: 1 :0
  2 :('u@[ (',(5!:5<'u'),') v@]')
)

  (i.2 3) $ $tine , p:i.3 2
2  3  5
7 11 13

FYI,

-- 
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
  
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] tine

2023-01-05 Thread 'Pascal Jasmin' via Programming
  M =: @]v2c =: 1 : '[. u ].'

tine =: 1 : ' (M~) (u v2c) M '
there was a recent change to allow gerund argument to &.
& and &: could allow gerund v such that w&(u`v)  is (u@[ w v@]).  But tine as 
written is easier to use (only one function.  no parenthesizing gerund 
arguments).



On Thursday, January 5, 2023 at 06:03:33 p.m. EST, Raul Miller 
 wrote:  
 
 Sometimes it seems like it would be nice to have a variation on fork
where instead of (f g h) we get *f@[ g h@])

And, of course, we can do that manually. (Also, I forget the contexts
where I have wanted to use this. Maybe I'll remember later. I also
have a vague memory of someone else asking for something like this.)

Anyways, it's fairly straightforward to implement, though perhaps a
bit tough to read (since mostly we don't mess with this kind of
thing):

tine=: 1 :0
  2 :('u@[ (',(5!:5<'u'),') v@]')
)

  (i.2 3) $ $tine , p:i.3 2
2  3  5
7 11 13

FYI,

-- 
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


Re: [Jprogramming] Beginner: Where to start?

2022-12-28 Thread 'Pascal Jasmin' via Programming
> J is an "array programming language," which is what exactly?

J is a functional programming language where every function is an operator with 
1 or 2 arguments.

An array language is one where arrays are easy to input, and functions 
"automatically" extend to full arrays with implied map/zip functionality.




On Wednesday, December 28, 2022 at 01:13:31 p.m. EST, Galaxy Being 
 wrote: 





Hello,

I would like to learn J programming paradigm. I have a standard programming
background (C/C++, Java) along with some basic math, as well as some
functional programming exposure. I understand, however, that J is an "array
programming language," which is what exactly? I've heard it is based on SKI
combinator math. Is this true? So my question is, What background
materials, texts, etc. should I study to get a theoretical understanding of
the J world? I watched this  and a few Tracy
Harms videos, so yes, where does a beginner get started -- especially with
the theory behind it all?

Thank you.
⨽
Lawrence Bottorff
Grand Marais, MN, USA
borg...@gmail.com
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] bug in `:6 WAS: Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
Thank you.  Great news.  I will test when beta comes out.






On Thursday, December 8, 2022 at 08:22:41 p.m. EST, Henry Rich 
 wrote: 





I realized that I could just run the verb without the y argument to get 
it back into normal order.

Then when I ran it on my current system it ran to completion!  The 
result was

+--+-+
|++-+++|4|
||jpqm|7 |
|++-+++| |
+--+-+

The difference is probably that just this afternoon I realized that F. 
didn't behave well in 5!:n, and also produced an empty result when 
appearing in (u f.) .  I fixed those bugs before running your test.

So I went back to an older version and reproduced the error you saw.  
After adding typeout to the script I see that the y argument being 
passed in to Fold_j_ is not a noun.  That produces chaos.

I'm going to hope that the bugs I fixed today got rid of the problem.  
The fixes might or might not be in the next beta.

Henry Rich

On 12/8/2022 8:13 PM, 'Pascal Jasmin' via Programming wrote:
> A definition of F02 that eliminates all of my other boiler plate or potential 
> sources of error is
>
>   F02 =: 2 : '(u`)(`v)(`:6)'  NB. still produces same reported errors
>
> + -: F02 +:
>
> -: + +:
>
> + {{-: u +:}}
>
> -: + +:
>
> + -: F02 +: 3
>
> 7.5
>
> activating debug does not interupt the " noun result was required" error
>
> full error is
>
> |noun result was required
> | fwd+rev
>
>
> which (fwd+rev) is expression that appears only in if. clause near top of 
> function.
>
>
>
> On Thursday, December 8, 2022 at 07:37:32 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> The noun result message comes from the execution of the Fold_j_ verb,
> which does the processing.  It means that somehow, in executing your u/v
> arguments, the result was not a noun.
>
> I don't understand your way of coding and don't want to.  If you can
> give a simple example of something that is creating a wrong result, I'll
> fix it.  I think you are right that there is a JE error, because it
> shouldn't be possible to get a non-noun result from executing a verb.
>
> The script that runs F. is ~addons/dev/fold/foldr.ijs.  You can add
> debug statements to that script to type out values so you can see what
> failed.  I would do this myself if your code were less baroque.
>
> Henry Rich
>
> On 12/8/2022 7:24 PM, 'Pascal Jasmin' via Programming wrote:
>> Not 100% sure it is bug in `:6 or the interaction with F..
>>
>> ex
>>
>> mjqjpqmgbljsphdztnvjfqwrcgsmlb
>>
>>     ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
>>{{(4;~4{.]) u (4}.])}} ex  NB. desired result
>>
>> ┌┬─┐
>>
>> │jpqm│7│
>>
>> └┴─┘
>>
>> where {{(4;~4{.]) u (4}.])}} is a preprocessing adverb alternative to a 
>> fork, that will make a fork from its binding.
>>
>> code dump:
>>
>> isNoun =: (0 = 4!:0 ::0:)@:<
>> isgerund =: 0:`(0 -.@e. 3 : ('a =. y (5!:0)';'1')"0)@.(0 < L.) :: 0:
>> ar =: 1 : '5!:1 <''u'''
>> ari =: 1 : 'if. isNoun ''u'' do. if. (isgerund -.@+.  -: ]) m do. m ar 
>> else. m end. else.u ar end.'
>> ti =: ari ` ari NB. different from doubleadverb2.ijs: '' is passed to ` . 
>> boxed non gerund is ar'd ie a:`u
>> ti2 =: ar ` ar
>> F0 =: 1 : 'u ti ti `: 6'
>> v2c =: 1 : '[. u ].'
>> F1 =: 1 : '(ti u) ti (ti) `:6'
>> F2 =: 1 : 'ti ti u `: 6'
>> F01 =: ((ti (2 : 'ti')))(`:6)
>> F02 =: 2 : '(u`)(`v)(`:6)'
>> F02 =: ( ([.(2 : 'ti')) (2 : 'ti' ].) ) (`:6)
>> F12 =: (2 : 'ti' ti) `: 6
>>
>> The F02 conjunction returns an adverb and is identical in function to 
>> {{(4;~4{.]) u (4}.])}} when it is used as  (4;~4{.]) F02 (4}.]) (ie. it 
>> binds params 0 and 2 of a fork, and waits to bind param 1 as an adverb)
>>
>>      (4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] 
>>F..) (4;~4{.]) F02 (4}.]) ex
>>
>> |noun result was required
>>
>> This seems like "too aggressive" invocation of "noun result expected" when 
>> `:6 is involved.  Perhaps as interaction with explicit conjuncitons.
>>
>> when "normal" parameters are given to adverb, everything works as expected.  
>> including with intervening adverbs.
>>
>> [ ]: (4;~4{.]) F02 (4}.]) ex
>>
>> ┌┬─┐
>>
>> │mjqj│4│
>>
>> └┴─┘
>>
>>
>>
>> The following displays are just the first line of multiline definition of 
>> Fold F..
>>
>>      ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
>>(4;~4{.]) F02 (4}.])
>>

Re: [Jprogramming] bug in `:6 WAS: Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
A definition of F02 that eliminates all of my other boiler plate or potential 
sources of error is

 F02 =: 2 : '(u`)(`v)(`:6)'  NB. still produces same reported errors

+ -: F02 +:

-: + +:

+ {{-: u +:}}

-: + +:

+ -: F02 +: 3

7.5

activating debug does not interupt the " noun result was required" error

full error is

|noun result was required
| fwd+rev


which (fwd+rev) is expression that appears only in if. clause near top of 
function.



On Thursday, December 8, 2022 at 07:37:32 p.m. EST, Henry Rich 
 wrote: 





The noun result message comes from the execution of the Fold_j_ verb, 
which does the processing.  It means that somehow, in executing your u/v 
arguments, the result was not a noun.

I don't understand your way of coding and don't want to.  If you can 
give a simple example of something that is creating a wrong result, I'll 
fix it.  I think you are right that there is a JE error, because it 
shouldn't be possible to get a non-noun result from executing a verb.

The script that runs F. is ~addons/dev/fold/foldr.ijs.  You can add 
debug statements to that script to type out values so you can see what 
failed.  I would do this myself if your code were less baroque.

Henry Rich

On 12/8/2022 7:24 PM, 'Pascal Jasmin' via Programming wrote:
> Not 100% sure it is bug in `:6 or the interaction with F..
>
> ex
>
> mjqjpqmgbljsphdztnvjfqwrcgsmlb
>
>   ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) {{(4;~4{.]) 
>u (4}.])}} ex  NB. desired result
>
> ┌┬─┐
>
> │jpqm│7│
>
> └┴─┘
>
> where {{(4;~4{.]) u (4}.])}} is a preprocessing adverb alternative to a fork, 
> that will make a fork from its binding.
>
> code dump:
>
> isNoun =: (0 = 4!:0 ::0:)@:<
> isgerund =: 0:`(0 -.@e. 3 : ('a =. y (5!:0)';'1')"0)@.(0 < L.) :: 0:
> ar =: 1 : '5!:1 <''u'''
> ari =: 1 : 'if. isNoun ''u'' do. if. (isgerund -.@+.  -: ]) m do. m ar 
> else. m end. else.u ar end.'
> ti =: ari ` ari NB. different from doubleadverb2.ijs: '' is passed to ` . 
> boxed non gerund is ar'd ie a:`u
> ti2 =: ar ` ar
> F0 =: 1 : 'u ti ti `: 6'
> v2c =: 1 : '[. u ].'
> F1 =: 1 : '(ti u) ti (ti) `:6'
> F2 =: 1 : 'ti ti u `: 6'
> F01 =: ((ti (2 : 'ti')))(`:6)
> F02 =: 2 : '(u`)(`v)(`:6)'
> F02 =: ( ([.(2 : 'ti')) (2 : 'ti' ].) ) (`:6)
> F12 =: (2 : 'ti' ti) `: 6
>
> The F02 conjunction returns an adverb and is identical in function to 
> {{(4;~4{.]) u (4}.])}} when it is used as  (4;~4{.]) F02 (4}.]) (ie. it binds 
> params 0 and 2 of a fork, and waits to bind param 1 as an adverb)
>
>    (4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
>(4;~4{.]) F02 (4}.]) ex
>
> |noun result was required
>
> This seems like "too aggressive" invocation of "noun result expected" when 
> `:6 is involved.  Perhaps as interaction with explicit conjuncitons.
>
> when "normal" parameters are given to adverb, everything works as expected.  
> including with intervening adverbs.
>
> [ ]: (4;~4{.]) F02 (4}.]) ex
>
> ┌┬─┐
>
> │mjqj│4│
>
> └┴─┘
>
>
>
> The following displays are just the first line of multiline definition of 
> Fold F..
>
>    ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) (4;~4{.]) 
>F02 (4}.])
>
> (4 ;~ 4 {. ]) ] (2 : 0) (((1 >:@({::) ]) ,&<~ [ ,~ _3 ({.) 0 {:: ])`(_2 Z: 
> 1:)@.(4 = 0 #@~.@({::) ])) 4 }. ] NB. first line leading multiline definition 
> (2 : 0 ) for F..
>
>
>
>     ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::])  (] F..) 
>{{(4;~4{.]) u (4}.])}}
> (4 ;~ 4 {. ]) ] (2 : 0) (((1 >:@({::) ]) ,&<~ [ ,~ _3 ({.) 0 {:: ])`(_2 Z: 
> 1:)@.(4 = 0 #@~.@({::) ])) 4 }. ]  NB. identical
>
> replacing the output of the F02 version for 2 : 0 with F.., is correct
>
>   ((4 ;~ 4 {. ]) ] F.. (((1 >:@({::) ]) ,&<~ [ ,~ _3 ({.) 0 {:: ])`(_2 Z: 
>1:)@.(4 = 0 #@~.@({::) ])) 4 }. ]) ex
>
> ┌┬─┐
>
> │jpqm│7│
>
> └┴─┘
>    
> all of the modifiers that use `:6 fail with the same error.  v2c (doesn't use 
> `:6, and is equivalent to F1) works.
>
> it doesn't appear to be a bug in "explicit conjunctions" (those that 
> reference x and y)
>
> - (+: 2 : 'x u@v y') -:@[ F02 (+:@])
>
> -:@[ +: (2 : (':'; 'x u@v y')) - +:@]
> :
>   2 - (+: 2 : 'x u@v y') -:@[ F02 (+:@]) 3
>
> _10  NB. 1 and 6 are result of v0 and v2.  1 +:@- 6 = _10
>
>
> One possible fix that would make everything cleaner is if (] F..) did not 
> expand to explicit definition.  It is not needed yet,as a primitive.
>
>
>
> On Thursday, December 8, 2022 at 02:34:58 p.m. EST, 'Pascal Jasmin' via 
> Programming  wrote:
>
>
>
>

Re: [Jprogramming] bug in `:6 WAS: Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
Not 100% sure it is bug in `:6 or the interaction with F..

ex

mjqjpqmgbljsphdztnvjfqwrcgsmlb

 ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) {{(4;~4{.]) u 
(4}.])}} ex  NB. desired result

┌┬─┐

│jpqm│7│

└┴─┘

where {{(4;~4{.]) u (4}.])}} is a preprocessing adverb alternative to a fork, 
that will make a fork from its binding.

code dump:

isNoun =: (0 = 4!:0 ::0:)@:<
isgerund =: 0:`(0 -.@e. 3 : ('a =. y (5!:0)';'1')"0)@.(0 < L.) :: 0:
ar =: 1 : '5!:1 <''u'''
ari =: 1 : 'if. isNoun ''u'' do. if. (isgerund -.@+.  -: ]) m do. m ar 
else. m end. else.u ar end.'
ti =: ari ` ari NB. different from doubleadverb2.ijs: '' is passed to ` . boxed 
non gerund is ar'd ie a:`u
ti2 =: ar ` ar
F0 =: 1 : 'u ti ti `: 6'
v2c =: 1 : '[. u ].'
F1 =: 1 : '(ti u) ti (ti) `:6'
F2 =: 1 : 'ti ti u `: 6'
F01 =: ((ti (2 : 'ti')))(`:6)
F02 =: 2 : '(u`)(`v)(`:6)'
F02 =: ( ([.(2 : 'ti')) (2 : 'ti' ].) ) (`:6)
F12 =: (2 : 'ti' ti) `: 6

The F02 conjunction returns an adverb and is identical in function to 
{{(4;~4{.]) u (4}.])}} when it is used as  (4;~4{.]) F02 (4}.]) (ie. it binds 
params 0 and 2 of a fork, and waits to bind param 1 as an adverb)

  (4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
(4;~4{.]) F02 (4}.]) ex

|noun result was required

This seems like "too aggressive" invocation of "noun result expected" when `:6 
is involved.  Perhaps as interaction with explicit conjuncitons.

when "normal" parameters are given to adverb, everything works as expected.  
including with intervening adverbs.

[ ]: (4;~4{.]) F02 (4}.]) ex

┌┬─┐

│mjqj│4│

└┴─┘



The following displays are just the first line of multiline definition of Fold 
F..

  ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) (4;~4{.]) F02 
(4}.]) 

(4 ;~ 4 {. ]) ] (2 : 0) (((1 >:@({::) ]) ,&<~ [ ,~ _3 ({.) 0 {:: ])`(_2 Z: 
1:)@.(4 = 0 #@~.@({::) ])) 4 }. ] NB. first line leading multiline definition 
(2 : 0 ) for F..



   ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::])  (] F..) {{(4;~4{.]) 
u (4}.])}}  
(4 ;~ 4 {. ]) ] (2 : 0) (((1 >:@({::) ]) ,&<~ [ ,~ _3 ({.) 0 {:: ])`(_2 Z: 
1:)@.(4 = 0 #@~.@({::) ])) 4 }. ]  NB. identical

replacing the output of the F02 version for 2 : 0 with F.., is correct

 ((4 ;~ 4 {. ]) ] F.. (((1 >:@({::) ]) ,&<~ [ ,~ _3 ({.) 0 {:: ])`(_2 Z: 
1:)@.(4 = 0 #@~.@({::) ])) 4 }. ]) ex

┌┬─┐

│jpqm│7│

└┴─┘
  
all of the modifiers that use `:6 fail with the same error.  v2c (doesn't use 
`:6, and is equivalent to F1) works.

it doesn't appear to be a bug in "explicit conjunctions" (those that reference 
x and y)

- (+: 2 : 'x u@v y') -:@[ F02 (+:@])

-:@[ +: (2 : (':'; 'x u@v y')) - +:@]
:
 2 - (+: 2 : 'x u@v y') -:@[ F02 (+:@]) 3

_10  NB. 1 and 6 are result of v0 and v2.  1 +:@- 6 = _10


One possible fix that would make everything cleaner is if (] F..) did not 
expand to explicit definition.  It is not needed yet,as a primitive.



On Thursday, December 8, 2022 at 02:34:58 p.m. EST, 'Pascal Jasmin' via 
Programming  wrote: 





mistake in Z definition found,

Zl =: ] [ _3 Z: [

makes this work, 

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl ]) 
F..) (4}.])) ex

but still

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl ]) 
F.) (4}.])) ex

|domain error




On Thursday, December 8, 2022 at 02:15:39 p.m. EST, 'Pascal Jasmin' via 
Programming  wrote: 





The short circuit you are trying to avoid is to skip the full partitioning part

4 #@~.\4 

one approach is to separate into the simplest possible partition, then hope 
that i. special code finds the short circuit.

4 + (1 i.~ 4 = #@~."1) 4 ]\ ex

your power approach is completely reasonable.

A fold approach is complicated by seeking the index rather than a "computed 
result"

There might be too much manipulated computation involved, but the general 
approach would be:

x parameter to fold is (a: ,< 0)  NB. initial y.
if head cell of y is shorter than 4, then append x to last 3 chars. (better to 
preprocess y such that x (to F.) has first 4 chars, and y omits first 4.)
if head is length 4, then apply test  ((1 >:@{:: ] ) ,&<~ [,~ _3{.0{::])`(_2 Z: 
1:)@.(4 = #@~. 0 {:: ])

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
(4}.])) ex
┌┬─┐
│jpqm│7│
└┴─┘
   
I don't understand why this fails:  (F. instead of F..)

Z =: ] [ Z:


   ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Z~ 
_3:) F.) (4}.])) ex

|domain error

or

 ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F.) 
(4}.])) ex

|domain error


also it is not documented whether F. or F: are forward or reverse.

On Thursday, December 8, 2022 at 11:28:12 a.m. EST, 'Michael Day' via 
Programming  

Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
I wanted to add that the Z: verb could have an option to return the index (or 
COUNT variable) instead of u y, since it is tracking a COUNT anyways to support 
_3:

This would allow the incremental scan approach (first one used) to not need to 
track the count itself in a hybrid/boxed y structure. 




On Thursday, December 8, 2022 at 06:01:45 p.m. EST, 'Pascal Jasmin' via 
Programming  wrote: 






Part of the complexity is searching for index rather than "data".  There are 
several convenience functions that can simplify the code

G0 =: 0 {:: ]
G1 =: 1 {:: ]
Z2 =: 2 : 'u`(_2 Z: 1:)@.v' NB. break when v is true. otherwise u.
Funtil =: Z2 (] F..) NB. fold until v is true, otherwise apply u (of fold).  
Uses old/new (C A) train.

Considering that we are using fold to replace dyadic scan, which it was not 
directly intended to do, it is not THAT complicated.
There is a preprocessing step that can be separated into an adverb, and reduce 
parentheses as a benefit.

1 :  '(4;~4{.]) u (4}.])' NB. instead of embedding the preprocessing step into 
"the fork" which impedes removing it or editing it.


((1>:@{::]),&<~[,~ _3{.0{::]) Funtil (4=0#@~.@{::]) {{(4;~4{.]) u (4}.])}} ex

or

(>:@G1,&<~ [,~ _3{.G0) Funtil (4 = #@~.@G0) {{(4;~4{.]) u (4}.])}} ex

and it is easy to turn it all into an adverb that parameterizes part 1 and 2

 5 {{ (>:@G1,&<~ [,~ (>: - m){.G0) Funtil (m = #@~.@G0) {{(n;~n{.]) u (n}.])}} 
m}} ex

┌─┬─┐

│jpqmg│8│

└─┴─┘

An alternative that maps the i. solution over preprocessed 4 ]\ ] scan (and 
then probably doesn't beat i. in performance?)
It looks at only x, and increments a single integer y when it doesn't "break"

4 {{m >:@] Funtil (m = #@~.@[) m ]\ ]}} ex

7



or hard coded

4 >:@] Funtil (4 = #@~.@[) 4 ]\  ex NB. 4 is x arg to F..

7

or the first string that matches ("better than i." if this is what you want as 
search result)

[ Funtil (4 = #@~.@]) 4 ]\ ex

jpqm



so there is still a relatively short version of the F.. approach for processing 
scans, if you do the scan first.


On Thursday, December 8, 2022 at 03:02:35 p.m. EST, 'Michael Day' via 
Programming  wrote: 





Thanks for your replies - I'll try to get round to understanding them.
It's a pity the Fold approach to this problem appears to need to be verbose.

Cheers,

Mike


On 08/12/2022 19:34, 'Pascal Jasmin' via Programming wrote:
> mistake in Z definition found,
>
> Zl =: ] [ _3 Z: [
>
> makes this work,
>
> ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl 
> ]) F..) (4}.])) ex
>
> but still
>
> ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl 
> ]) F.) (4}.])) ex
>
> |domain error
>
>
>
>
> On Thursday, December 8, 2022 at 02:15:39 p.m. EST, 'Pascal Jasmin' via 
> Programming  wrote:
>
>
>
>
>
> The short circuit you are trying to avoid is to skip the full partitioning 
> part
>
> 4 #@~.\4
>
> one approach is to separate into the simplest possible partition, then hope 
> that i. special code finds the short circuit.
>
> 4 + (1 i.~ 4 = #@~."1) 4 ]\ ex
>
> your power approach is completely reasonable.
>
> A fold approach is complicated by seeking the index rather than a "computed 
> result"
>
> There might be too much manipulated computation involved, but the general 
> approach would be:
>
> x parameter to fold is (a: ,< 0)  NB. initial y.
> if head cell of y is shorter than 4, then append x to last 3 chars. (better 
> to preprocess y such that x (to F.) has first 4 chars, and y omits first 4.)
> if head is length 4, then apply test  ((1 >:@{:: ] ) ,&<~ [,~ _3{.0{::])`(_2 
> Z: 1:)@.(4 = #@~. 0 {:: ])
>
> ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
> (4}.])) ex
> ┌┬─┐
> │jpqm│7│
> └┴─┘
>    
> I don't understand why this fails:  (F. instead of F..)
>
> Z =: ] [ Z:
>
>
>     ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 
>Z~ _3:) F.) (4}.])) ex
>
> |domain error
>
> or
>
>   ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F.) 
>(4}.])) ex
>
> |domain error
>
>
> also it is not documented whether F. or F: are forward or reverse.
>
> On Thursday, December 8, 2022 at 11:28:12 a.m. EST, 'Michael Day' via 
> Programming  wrote:
>
>
>
>
>
> Having remarked recently (re Advent of Code day 6):
>
>      Very easy today, in J at least,  and probably in APL & K/Q. (Though it
>      suggests one should learn the new fold features,  as it's inefficient to
>      examine all the data for something that might occur early.  No problem
>      with 4kb,  but 

Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming

Part of the complexity is searching for index rather than "data".  There are 
several convenience functions that can simplify the code

G0 =: 0 {:: ]
G1 =: 1 {:: ]
Z2 =: 2 : 'u`(_2 Z: 1:)@.v' NB. break when v is true. otherwise u.
Funtil =: Z2 (] F..) NB. fold until v is true, otherwise apply u (of fold).  
Uses old/new (C A) train.

Considering that we are using fold to replace dyadic scan, which it was not 
directly intended to do, it is not THAT complicated.
There is a preprocessing step that can be separated into an adverb, and reduce 
parentheses as a benefit.

1 :  '(4;~4{.]) u (4}.])' NB. instead of embedding the preprocessing step into 
"the fork" which impedes removing it or editing it.


((1>:@{::]),&<~[,~ _3{.0{::]) Funtil (4=0#@~.@{::]) {{(4;~4{.]) u (4}.])}} ex

or

(>:@G1,&<~ [,~ _3{.G0) Funtil (4 = #@~.@G0) {{(4;~4{.]) u (4}.])}} ex

and it is easy to turn it all into an adverb that parameterizes part 1 and 2

 5 {{ (>:@G1,&<~ [,~ (>: - m){.G0) Funtil (m = #@~.@G0) {{(n;~n{.]) u (n}.])}} 
m}} ex

┌─┬─┐

│jpqmg│8│

└─┴─┘

An alternative that maps the i. solution over preprocessed 4 ]\ ] scan (and 
then probably doesn't beat i. in performance?)
It looks at only x, and increments a single integer y when it doesn't "break"

4 {{m >:@] Funtil (m = #@~.@[) m ]\ ]}} ex

7



or hard coded

4 >:@] Funtil (4 = #@~.@[) 4 ]\  ex NB. 4 is x arg to F..

7

or the first string that matches ("better than i." if this is what you want as 
search result)

[ Funtil (4 = #@~.@]) 4 ]\ ex

jpqm



so there is still a relatively short version of the F.. approach for processing 
scans, if you do the scan first.


On Thursday, December 8, 2022 at 03:02:35 p.m. EST, 'Michael Day' via 
Programming  wrote: 





Thanks for your replies - I'll try to get round to understanding them.
It's a pity the Fold approach to this problem appears to need to be verbose.

Cheers,

Mike


On 08/12/2022 19:34, 'Pascal Jasmin' via Programming wrote:
> mistake in Z definition found,
>
> Zl =: ] [ _3 Z: [
>
> makes this work,
>
> ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl 
> ]) F..) (4}.])) ex
>
> but still
>
> ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl 
> ]) F.) (4}.])) ex
>
> |domain error
>
>
>
>
> On Thursday, December 8, 2022 at 02:15:39 p.m. EST, 'Pascal Jasmin' via 
> Programming  wrote:
>
>
>
>
>
> The short circuit you are trying to avoid is to skip the full partitioning 
> part
>
> 4 #@~.\4
>
> one approach is to separate into the simplest possible partition, then hope 
> that i. special code finds the short circuit.
>
> 4 + (1 i.~ 4 = #@~."1) 4 ]\ ex
>
> your power approach is completely reasonable.
>
> A fold approach is complicated by seeking the index rather than a "computed 
> result"
>
> There might be too much manipulated computation involved, but the general 
> approach would be:
>
> x parameter to fold is (a: ,< 0)  NB. initial y.
> if head cell of y is shorter than 4, then append x to last 3 chars. (better 
> to preprocess y such that x (to F.) has first 4 chars, and y omits first 4.)
> if head is length 4, then apply test  ((1 >:@{:: ] ) ,&<~ [,~ _3{.0{::])`(_2 
> Z: 1:)@.(4 = #@~. 0 {:: ])
>
> ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
> (4}.])) ex
> ┌┬─┐
> │jpqm│7│
> └┴─┘
>    
> I don't understand why this fails:  (F. instead of F..)
>
> Z =: ] [ Z:
>
>
>     ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 
>Z~ _3:) F.) (4}.])) ex
>
> |domain error
>
> or
>
>   ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F.) 
>(4}.])) ex
>
> |domain error
>
>
> also it is not documented whether F. or F: are forward or reverse.
>
> On Thursday, December 8, 2022 at 11:28:12 a.m. EST, 'Michael Day' via 
> Programming  wrote:
>
>
>
>
>
> Having remarked recently (re Advent of Code day 6):
>
>      Very easy today, in J at least,  and probably in APL & K/Q. (Though it
>      suggests one should learn the new fold features,  as it's inefficient to
>      examine all the data for something that might occur early.  No problem
>      with 4kb,  but )
>
> I've just had a look at the Jwiki entries about Fold,  and wonder how it
> would work
> for day 6.
>
> The problem is so easy for J-ers that I don't think this will spoil it
> for forum users:
>     ex
> mjqjpqmgbljsphdztnvjfqwrcgsmlb
>     4 + 4 i.~ 4 #@~.\ ex
> 7
>
> QED
>
>     #data   NB. the size of my data set
> 4096
>     ts'4 + 4 i.~ 4 #@~.\ d

Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
u^:_ will terminate/escape/stop once u y (repeated) results in the fixed point 
of y = u y.






On Thursday, December 8, 2022 at 03:04:28 p.m. EST, Henry Rich 
 wrote: 





Right.  I don't know what you mean by 'fixed point escape'.  You get out 
with Z:, and the result is the last value or all of them.

Henry Rich

On 12/8/2022 3:02 PM, 'Pascal Jasmin' via Programming wrote:
> so F. is like ^:_ , but instead of ^:(while true test)^:_ , use Z: to escape 
> it?  There is no fixed point escape?
>
>
>
>
>
>
> On Thursday, December 8, 2022 at 02:46:01 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> no.
>
> Henry Rich
>
> On 12/8/2022 2:38 PM, 'Pascal Jasmin' via Programming wrote:
>> are they forward or reverse?
>>
>>
>>
>>
>>
>>
>> On Thursday, December 8, 2022 at 02:25:18 p.m. EST, Henry Rich 
>>  wrote:
>>
>>
>>
>>
>>
>> Pascal wrote:
>>
>>> also it is not documented whether F. or F: are forward or reverse.
>> As indicated in
>> https://code.jsoftware.com/wiki/Vocabulary/fcap#Limited_vs_unlimited ,
>> they are not.
>>
>> Henry Rich
>>
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> --
>> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
so F. is like ^:_ , but instead of ^:(while true test)^:_ , use Z: to escape 
it?  There is no fixed point escape?






On Thursday, December 8, 2022 at 02:46:01 p.m. EST, Henry Rich 
 wrote: 





no.

Henry Rich

On 12/8/2022 2:38 PM, 'Pascal Jasmin' via Programming wrote:
> are they forward or reverse?
>
>
>
>
>
>
> On Thursday, December 8, 2022 at 02:25:18 p.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> Pascal wrote:
>
>> also it is not documented whether F. or F: are forward or reverse.
> As indicated in
> https://code.jsoftware.com/wiki/Vocabulary/fcap#Limited_vs_unlimited ,
> they are not.
>
> Henry Rich
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
are they forward or reverse?






On Thursday, December 8, 2022 at 02:25:18 p.m. EST, Henry Rich 
 wrote: 





Pascal wrote:

> also it is not documented whether F. or F: are forward or reverse.

As indicated in 
https://code.jsoftware.com/wiki/Vocabulary/fcap#Limited_vs_unlimited , 
they are not.

Henry Rich

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


Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
mistake in Z definition found,

Zl =: ] [ _3 Z: [

makes this work, 

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl ]) 
F..) (4}.])) ex

but still

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Zl ]) 
F.) (4}.])) ex

|domain error




On Thursday, December 8, 2022 at 02:15:39 p.m. EST, 'Pascal Jasmin' via 
Programming  wrote: 





The short circuit you are trying to avoid is to skip the full partitioning part

4 #@~.\4 

one approach is to separate into the simplest possible partition, then hope 
that i. special code finds the short circuit.

4 + (1 i.~ 4 = #@~."1) 4 ]\ ex

your power approach is completely reasonable.

A fold approach is complicated by seeking the index rather than a "computed 
result"

There might be too much manipulated computation involved, but the general 
approach would be:

x parameter to fold is (a: ,< 0)  NB. initial y.
if head cell of y is shorter than 4, then append x to last 3 chars. (better to 
preprocess y such that x (to F.) has first 4 chars, and y omits first 4.)
if head is length 4, then apply test  ((1 >:@{:: ] ) ,&<~ [,~ _3{.0{::])`(_2 Z: 
1:)@.(4 = #@~. 0 {:: ])

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
(4}.])) ex
┌┬─┐
│jpqm│7│
└┴─┘
   
I don't understand why this fails:  (F. instead of F..)

Z =: ] [ Z:


   ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Z~ 
_3:) F.) (4}.])) ex

|domain error

or

 ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F.) 
(4}.])) ex

|domain error


also it is not documented whether F. or F: are forward or reverse.

On Thursday, December 8, 2022 at 11:28:12 a.m. EST, 'Michael Day' via 
Programming  wrote: 





Having remarked recently (re Advent of Code day 6):

    Very easy today, in J at least,  and probably in APL & K/Q. (Though it
    suggests one should learn the new fold features,  as it's inefficient to
    examine all the data for something that might occur early.  No problem
    with 4kb,  but )

I've just had a look at the Jwiki entries about Fold,  and wonder how it 
would work
for day 6.

The problem is so easy for J-ers that I don't think this will spoil it 
for forum users:
   ex
mjqjpqmgbljsphdztnvjfqwrcgsmlb
   4 + 4 i.~ 4 #@~.\ ex
7

QED

   #data   NB. the size of my data set
4096
   ts'4 + 4 i.~ 4 #@~.\ data'   NB.  time & space
0.0008555 67232

I didn't bother making a function for this!

One way to stop early,  rather than process the whole array, is this:
   ts'4 + (# - #@:((}.`])@.(4&([ = #@:~.@:{.))^:_)) data'
0.0007299 4736

(I know it's ugly,  and non-optimal!)

Similar time but with ca 14x space-saving.

But there must be some sort of Fold to progressively examine 4-windows,
or 14-windows in part 2,  until the first appropriate window is found,  
when
it stops.   That should save time as well as space.  Not necessary 
here,  of
course,  but if there was a real application with many megabytes of data...

Cheers,

Mike



On 06/12/2022 19:46, Brian Schott wrote:
> I have successfully solved Day 5 using the following looping verb `tomove`
> but cannot craft a Fold version, and would like help.
>
> *[FYI I have included an attachment that seems to load and execute
> properly, but I could NOT get the email versions to load correctly,
> presumably because of some funny characters.]*
>
> tomove=: dyad define
> while. #y do.
> x=.x move {. y
> y =. }.y
> end.
> x
> )
>
>
> NB. The verb `move` for part 1 is very simple:
>
> move =: dyad define
> 'n f t'=. _1 1 1*y - 0 1 1
> take =. |.n{.>f{x
> left =. f{x
> put =. t{x
> (left,put) (f,t)}x
> )
>
> NB. the inputs are produced as follows.
>
> top =: 0 :0
>      [D]
> [N] [C]
> [Z] [M] [P]
>  1  2  3
> )
>
> state=.deb each ;/ |:|.}:1 5 9&{;._2 top
>
> bottom =: 0 :0
> move 1 from 2 to 1
> move 3 from 1 to 3
> move 2 from 2 to 1
> move 1 from 1 to 2
> )
> alpha =. a. {~97+i.26
> moves =. ".-. ;._2 bottom
>
> NB. finally the result is produced by the next phrase
>
> {:every state tomove moves
>
>
> --
> For information about J forums seehttp://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Is there a Fold for AOC day 6? - was Re: Questions on Advent of code Day 5

2022-12-08 Thread 'Pascal Jasmin' via Programming
The short circuit you are trying to avoid is to skip the full partitioning part

4 #@~.\4 

one approach is to separate into the simplest possible partition, then hope 
that i. special code finds the short circuit.

4 + (1 i.~ 4 = #@~."1) 4 ]\ ex

your power approach is completely reasonable.

A fold approach is complicated by seeking the index rather than a "computed 
result"

There might be too much manipulated computation involved, but the general 
approach would be:

x parameter to fold is (a: ,< 0)  NB. initial y.
if head cell of y is shorter than 4, then append x to last 3 chars. (better to 
preprocess y such that x (to F.) has first 4 chars, and y omits first 4.)
if head is length 4, then apply test  ((1 >:@{:: ] ) ,&<~ [,~ _3{.0{::])`(_2 Z: 
1:)@.(4 = #@~. 0 {:: ])

((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F..) 
(4}.])) ex
┌┬─┐
│jpqm│7│
└┴─┘
   
I don't understand why this fails:  (F. instead of F..)

Z =: ] [ Z:


   ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) ((100 Z~ 
_3:) F.) (4}.])) ex

|domain error

or

 ((4;~4{.]) ((1>:@{::]),&<~[,~ _3{.0{::])`(_2 Z:1:)@.(4=0#@~.@{::]) (] F.) 
(4}.])) ex

|domain error


also it is not documented whether F. or F: are forward or reverse.

On Thursday, December 8, 2022 at 11:28:12 a.m. EST, 'Michael Day' via 
Programming  wrote: 





Having remarked recently (re Advent of Code day 6):

    Very easy today, in J at least,  and probably in APL & K/Q. (Though it
    suggests one should learn the new fold features,  as it's inefficient to
    examine all the data for something that might occur early.  No problem
    with 4kb,  but )

I've just had a look at the Jwiki entries about Fold,  and wonder how it 
would work
for day 6.

The problem is so easy for J-ers that I don't think this will spoil it 
for forum users:
   ex
mjqjpqmgbljsphdztnvjfqwrcgsmlb
   4 + 4 i.~ 4 #@~.\ ex
7

QED

   #data   NB. the size of my data set
4096
   ts'4 + 4 i.~ 4 #@~.\ data'   NB.  time & space
0.0008555 67232

I didn't bother making a function for this!

One way to stop early,  rather than process the whole array, is this:
   ts'4 + (# - #@:((}.`])@.(4&([ = #@:~.@:{.))^:_)) data'
0.0007299 4736

(I know it's ugly,  and non-optimal!)

Similar time but with ca 14x space-saving.

But there must be some sort of Fold to progressively examine 4-windows,
or 14-windows in part 2,  until the first appropriate window is found,  
when
it stops.   That should save time as well as space.  Not necessary 
here,  of
course,  but if there was a real application with many megabytes of data...

Cheers,

Mike



On 06/12/2022 19:46, Brian Schott wrote:
> I have successfully solved Day 5 using the following looping verb `tomove`
> but cannot craft a Fold version, and would like help.
>
> *[FYI I have included an attachment that seems to load and execute
> properly, but I could NOT get the email versions to load correctly,
> presumably because of some funny characters.]*
>
> tomove=: dyad define
> while. #y do.
> x=.x move {. y
> y =. }.y
> end.
> x
> )
>
>
> NB. The verb `move` for part 1 is very simple:
>
> move =: dyad define
> 'n f t'=. _1 1 1*y - 0 1 1
> take =. |.n{.>f{x
> left =. f{x
> put =. t{x
> (left,put) (f,t)}x
> )
>
> NB. the inputs are produced as follows.
>
> top =: 0 :0
>      [D]
> [N] [C]
> [Z] [M] [P]
>  1  2  3
> )
>
> state=.deb each ;/ |:|.}:1 5 9&{;._2 top
>
> bottom =: 0 :0
> move 1 from 2 to 1
> move 3 from 1 to 3
> move 2 from 2 to 1
> move 1 from 1 to 2
> )
> alpha =. a. {~97+i.26
> moves =. ".-. ;._2 bottom
>
> NB. finally the result is produced by the next phrase
>
> {:every state tomove moves
>
>
> --
> For information about J forums seehttp://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Questions on Advent of code Day 5

2022-12-07 Thread 'Pascal Jasmin' via Programming
All programming languages can have their function definitions understood as a 
template where "parameter variables" get substituted with their parameter 
values when called.

in J, explicit verbs have x and y parameter variables, while tacit or built-in 
verbs can/are documented as if x and y were explicitly included.

The identity adverb:  1 :'u' (new in 9.04 ]:) where u is a verb is identical to

1 : 0
u y
:
x u y
)

  
An adverb just has 1 "core" parameter: u.  A conjunction has 2: u and v.

The long version of the identity adverb template above has additional explicit 
verb arguments, as a single template.  The short version can be understood as 
returning a new template, but with implicit parameters that make a template 
unneeded (because the template is just implied) 

"And since Raul defined his explicitly, he was required to use `u` instead of 
`v`"


I'd word that as Raul defined an adverb.  The only template variable in an 
adverb definition is `u`

Every conjunction C has an implied template equivalent to the explicit:  2 : 'u 
C v'

other equivalencies are:
u(C v)
v(u C)

binding one parameter with a Conjunction results in an adverb that only 
requires one more parameter to "fully bind original conjunction"

Raul's lfold definition is equivalent to

1 : '] {{u F.. v}} (u~)'

the "internal expansion" of F.. is not visible to the (external) adverb 
definition.  Once u is provided though, (u~) will be inserted into F.. 's 
template as it's v parameter.  F.. 's u parameter is fixed as ]

My tacit version has explicit equivalent of

1 : 'u~(] {{u F.. v}}) '

] is still fixed as u to F.. making that fixing an adverb
the ~ adverb will modify u before forwarding the result to the above adverb.
template substitution of u in the adverb definition will complete the v 
(internal template) parameter to F.. and complete the binding of F..
Fully bound F.. becomes a verb with implied y and possibly x template 
parameters.


On Wednesday, December 7, 2022 at 09:45:45 a.m. EST, Brian Schott 
 wrote: 





Pascal,

The most important thing I learned/remembered from your reply is that your
lfold is an adverb (that happens to be constructed from a pair of adverbs
in an adverb train).
That helped me understand that Raul's lfold is an adverb, too, but defined
explicitly, where yours is defined implicitly.
And since Raul defined his explicitly, he was required to use `u` instead
of `v` . So that registers for me.
Right?

So let's (re)name the adverbs as follows.
And the mock session excerpt below is meant to demonstrate that they
produce the same result.

lfoldR =: {{ ]F..(u~) }}
lfoldP =: ~(] F..)  NB. Adverb train

NB. (It's a little odd that `~` appears on the right
NB. of u in Raul's fold, but as the left adverb in
NB. your adverb train. But that works for me.)

lfoldP =: ~(] F..)
state move lfoldP moves
NB. ┌─┬─┬┐
NB. │C│M│PDNZ│
NB. └─┴─┴┘
lfoldR=: {{ ]F..(u~) }}
state move lfoldR moves
NB. ┌─┬─┬┐
NB. │C│M│PDNZ│
NB. └─┴─┴┘

*Many thanks to you and to Raul and Henry*,


On Tue, Dec 6, 2022 at 7:56 PM 'Pascal Jasmin' via Programming <
programm...@jsoftware.com> wrote:

> To clarify,
>
> A conjunction F.. in this case, is documented according to the same
> explicit defintion:  either 2 : 'u F.. v' or {{u F.. v}}
>
> In the above explicit definitions u is left argument to F..  v is right
> argument.
>
> lfold is an adverb. Has just one left argument u.  That adverb will place
> its u argument in "the v position" of F..
>
> a tacit versions of lfold
>
> lfold =: ~(] F..)  NB. Adverb train
>
> for easier display
>
> - ~(+: @:)
>
> +:@:(-~)
>
>  2 - ~(+: @:)3
>
> 2
>
>  +: 2 -~ 3
>
> 2
>
>
>
>
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Questions on Advent of code Day 5

2022-12-06 Thread 'Pascal Jasmin' via Programming
To clarify,

A conjunction F.. in this case, is documented according to the same explicit 
defintion:  either 2 : 'u F.. v' or {{u F.. v}}

In the above explicit definitions u is left argument to F..  v is right 
argument.

lfold is an adverb. Has just one left argument u.  That adverb will place its u 
argument in "the v position" of F..

a tacit versions of lfold

lfold =: ~(] F..)  NB. Adverb train

for easier display

- ~(+: @:)

+:@:(-~)

 2 - ~(+: @:)3

2

 +: 2 -~ 3

2


On Tuesday, December 6, 2022 at 06:31:21 p.m. EST, Henry Rich 
 wrote: 





No, u is the left argument and v is the right.  u@v for example.

Henry Rich

On 12/6/2022 6:29 PM, Brian Schott wrote:
> Raul,
>
> I'm beginning to understand your explanation of  lfold=: {{ ]F..(u~) }} .
> You're saying that j conjunctions have a left and right argument we call v
> and u, respectively
> (from the perspective of the interpreter).
> In that context, u is on the right of the conjunction, and that's why you
> used u here,
> not because it's the u in Folds. That is confusing, but I can accept that.
> Thank you, again,
>
> On Tue, Dec 6, 2022 at 5:36 PM Raul Miller  wrote:
>
>> Context is important here.
>>
>> In
>>    lfold=: {{ ]F..(u~) }}
>>
>> The u for lfold is the v for F..
>>
>> The J parser is not going to interpret u or v according to some
>> referenced definition -- it's going to interpret u or v according to
>> the definition it's currently interpreting.
>>
>> The same holds for x and y.
>>
>> Consider this example:
>>
>>    thing1=: {{ y thing2 x }}
>>    thing2=: ,&<
>>    thing1/i.3
>> +-+-+
>> |+-+-+|0|
>> ||2|1|| |
>> |+-+-+| |
>> +-+-+
>>    thing2/i.3
>> +-+-+
>> |0|+-+-+|
>> | ||1|2||
>> | |+-+-+|
>> +-+-+
>>
>> I hope this makes sense...
>>
>> --
>> 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
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Catenating columns.

2022-12-06 Thread 'Pascal Jasmin' via Programming
The key is rank, and dyadic rank "

u"(l, r) is u(" l r), where l and r specify the cell size of x and y for how u 
will be applied.

,"_ 0 is u = ,  l = _ r = 0


54 48,"1 0 i.10  NB. produces same result.

u"0 means apply u to atoms
u"1 to rows at a time
u"2 to tables at a time
u"_ to whole argument.


understanding ,"(l,r) is more important than knowing ,. exists for me because I 
usually forget its ,"(l,r) equivalence, and ," is always more intentful.  " 
being applicable to all J verbs makes it a very important concept.  Using it 
with , is a good way to experiment with it, and will usually provide a way to 
"stitch" parameters in all the ways you might want to.

On Tuesday, December 6, 2022 at 04:49:54 p.m. EST, 'Skip Cave' via Programming 
 wrote: 





Elijah,
that's what I want!

54 48,"_ 0 i.10

54 48 0

54 48 1

54 48 2

54 48 3

54 48 4

54 48 5

54 48 6

54 48 7

54 48 8

54 48 9


Where can I find the documentation on *,"_ 0 * ??


Skip Cave
Cave Consulting LLC


On Tue, Dec 6, 2022 at 1:32 AM Elijah Stone  wrote:

> ,. is ,"_1; in other words, catenate corresponding cells of each argument.
> 54 48 has 2 cells, but i.10 has 10 cells; that doesn't work.
>
> Perhaps you want 54 48 ,"_ 0 i.10.
>
> On Tue, 6 Dec 2022, 'Skip Cave' via Programming wrote:
>
> > I can add a column of increasing integers to a fixed integer:
> >
> > 48,.i.10
> >
> > 48 0
> >
> > 48 1
> >
> > 48 2
> >
> > 48 3
> >
> > 48 4
> >
> > 48 5
> >
> > 48 6
> >
> > 48 7
> >
> > 48 8
> >
> > 48 9
> >
> >
> > Now I want to add the same increasing column to *two* fixed integers:
> >
> > 54 48,.i.10
> >
> > |length error
> >
> > | 54 48 ,.i.10
> >
> >
> > Why doesn't this work?
> >
> > Skip Cave
> > Cave Consulting LLC
> > --
> > For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] EVM

2022-12-03 Thread 'Pascal Jasmin' via Programming
The display for that page tries to "make columnar" results of raw expression 
and EVM expression.  The lines are not legal J.

'*: 4' EVM  NB. should work

*: 4 '*: 4' EVM  NB. results in N N - syntax error.






On Saturday, December 3, 2022 at 07:14:41 a.m. EST, Richard Donovan 
 wrote: 





I was reading on the J website of the useful sounding adverb EVM so I went to 
the link at Help / Learning / Ap 1: Evaluating Expressions - J Wiki 
(jsoftware.com)
 and downloaded it.

So far I cannot get it to work at all using the examples given, I get syntax 
error in every case! EG

From the wiki page...
*: 4
'*: 4' EVM
16
16

Me:

*: 4'*: 4' EVM
|syntax error
| *: 4'*: 4'EVM

Have I catastrophically misunderstood this, or missed something obvious??

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


Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread 'Pascal Jasmin' via Programming
your select function ev can be replaced with

ev =: (9 3$'A XA YA ZB XB YB ZC XC YC Z')&(4 8 3 1 5 9 7 2 6 { ~ i.)

ev 'A X'

4





On Friday, December 2, 2022 at 12:40:53 p.m. EST, Jaume  
wrote: 





Hello again
I managed to solve it, but I don't like it much, so feel free to educate me.

Reading the file, and evaluating the result is something that looked nice:

p =. 1!:1<'day02.input'

+/>ev each cutopen p



+/>ev2 each cutopen p



Now are the evaluating functions. I really don't like how they are done.
I'd even prefer to create a table and search in it, but I don't know how.
So a select. is used.


ev=: 3 : 0

select. y

case. 'A X' do.

4

case. 'A Y' do.

8

case. 'A Z' do.

3

case. 'B X' do.

1

case. 'B Y' do.

5

case. 'B Z' do.

9

case. 'C X' do.

7

case. 'C Y' do.

2

case. 'C Z' do.

6

end.

)


And the same with different numbers for ev2.

Would this be an appropriate way to approach the problem? Is there a
"better" way?


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


Re: [Jprogramming] Nub with extra column

2022-11-24 Thread 'Pascal Jasmin' via Programming
can duplicate on windows, both of these are fast:

~. 1 ,.~ ?. 100 2$100

~. 1 ,.~ ?. 100 4$100





On Thursday, November 24, 2022 at 12:40:33 a.m. EST, Elijah Stone 
 wrote: 





That looks rather serious.  It seems some problem with the hashing function is 
causing an unreasonably high rate of collisions.  As a temporary workaround, 
you can try using ~.&.:(1&|."1), or use the 32-bit version.

On Thu, 24 Nov 2022, Ben Gorte wrote:

> G'day,
>
>
> Still J-ing along, I believe I ran into a little performance issue.
>
> I can strip it down into:
>
>
> A3=:?100 3$100 NB. three columns of random numbers 0 .. 99
>
> A31 =: A3,.1 NB. with an extra column of 1-s
>
> A4=:?100 4$100 NB. or four random columns
>
> 6!:2 'echo $~.A3'
>
> 632783 3
>
> 0.037673
>
> 6!:2 'echo $~.A31'
>
> 632783 4
>
> 24.6091
>
> That's 600 times longer!
>
>
> However,
>
> 6!:2 'echo $~.A4'
>
> 995025 4
>
> 0.43277
>
> is again much quicker.
>
>
> This is consistent over versions 807, 903 and 904, all with Ubuntu linux.
>
>
> I do need the fourth column and it has many 1-s (not all).
>
>
> Thanks,
>
> Ben
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Feedback on the proposed design of the J wiki

2022-11-23 Thread 'Pascal Jasmin' via Programming
I like it.  The video did point out useful features I would not have found on 
my own.  But, also don't need to be at forefront.

The landing page did give me a first impression of a  very childlike retro vibe 
with the colours.  I quickly got used to it.





On Wednesday, November 23, 2022 at 05:32:19 p.m. EST, 'robert therriault' via 
Programming  wrote: 





Our proposed front end for the new J wiki is in its final design stages and I 
have just posted a video that shows some of the affordances that the new design 
provides.

What we are looking for are comments on the approaches that we have taken. What 
you like and what you don't. We're not saying that every wish will be granted, 
but they all will be appreciated and will help form the approach going forward.

Here is the video: https://www.youtube.com/watch?v=_aQxyZdjtW4

And if you have not looked at the prototype wiki lately, her is its location: 
https://code2.jsoftware.com/wiki/Main_Page

We are looking forward to your responses.

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


Re: [Jprogramming] Truncating primes

2022-11-21 Thread 'Pascal Jasmin' via Programming
props for using { catalogue and managing a &. application in your step function.


a design principle I was aiming for is a big strength of J.  What I call a 
"perfect function" defined as iterative form where output is of consistent 
shape/meaning as input, and where ^: can be used "separately" to get the 
iterations.  It means debug free explorative programing.  Use adverbs to 
integrate extra/domain functionality above the "perfect function"

Your "step" function is actually more pure/more perfect than my ltrunc because 
it just returns the raw result of the next iteration.

(1 + i.9) step < 3 7

13 17 23 37 43 47 53 67 73 83 97

to use your step function to get the "exploratory structure" I want/ed just 
with adverbs

 H =: 2 : 'u v'

 > {: (1 + i.9) step H {: ((<@) ,~ ])^:(2) < 3 7 

113 137 167 173 197 223 283 313 317 337 347 353 367 373 383 397 443 467 523 547 
613 617 643 647 653 673 683 743 773 797 823 853 883 937 947 953 967 983 997

The function and adverbs will still work with data that is truncated to the 
last iteration, perhaps if exploration results in memory constraints.  Compared 
to ^:a: or ^:(i.n), there are no shape/fill cleanups to obtain the count of 
each iteration result.

for completeness, a right truncated primes generation function.

original, just edit of my less than fully perfect ltrunc

rtrunc1 =: (] , ((1 3 7 9) (10 #. ,~)"0 1 

Re: [Jprogramming] Truncating primes

2022-11-20 Thread 'Pascal Jasmin' via Programming
based on Raul's rosettacode link, but building an expaning list of left 
truncable primes, such that further search is possible on future "iterations"


 selPrime=: #~ 1:

ltrunc =: (] , ((1+i.9) (10 #. ,)"0 1 

Re: [Jprogramming] J blind spot

2022-10-21 Thread 'Pascal Jasmin' via Programming
if you want the index rather than the coordinate values, then

(1 i.~ f) y

will "short circuit" to the first 1

and 

({~ 1 i.~ f)

may be faster to get first coordinates than my original solution, though errors 
if there are no items with 1 = f




On Friday, October 21, 2022 at 12:55:41 p.m. EDT, 'Pascal Jasmin' via 
Programming  wrote: 





}.^:(0 = f@{.)^:_

will return the list with the head being the first f not equal 0.






On Friday, October 21, 2022 at 12:19:41 p.m. EDT, Ed Gottsman 
 wrote: 





Hi.  I’m blanking on something basic and research isn’t helping.  When the 
blindingly obvious solution is revealed I will blame a combination of sleep 
deprivation and senescence.

I’ve got a long list of coordinates ordered by desirability.  I want to invoke 
f (a custom script) with each coordinate in turn.  f may return 0 (failure), in 
which case I want to invoke it again with the next coordinate.  When f 
(eventually) returns 1, I want to terminate—the remainder of the coordinates 
should not be processed.  (Note that the very first invocation of f may return 
1.)

This *almost* feels like ^: in its Do While form.  Almost.  It also feels like 
SCs around list operations (though they seem to be limited to primitives).

Help.

Many thanks.

Ed

Sent from my iPad
--
For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] J blind spot

2022-10-21 Thread 'Pascal Jasmin' via Programming
}.^:(0 = f@{.)^:_

will return the list with the head being the first f not equal 0.






On Friday, October 21, 2022 at 12:19:41 p.m. EDT, Ed Gottsman 
 wrote: 





Hi.  I’m blanking on something basic and research isn’t helping.  When the 
blindingly obvious solution is revealed I will blame a combination of sleep 
deprivation and senescence.

I’ve got a long list of coordinates ordered by desirability.  I want to invoke 
f (a custom script) with each coordinate in turn.  f may return 0 (failure), in 
which case I want to invoke it again with the next coordinate.  When f 
(eventually) returns 1, I want to terminate—the remainder of the coordinates 
should not be processed.  (Note that the very first invocation of f may return 
1.)

This *almost* feels like ^: in its Do While form.  Almost.  It also feels like 
SCs around list operations (though they seem to be limited to primitives).

Help.

Many thanks.

Ed

Sent from my iPad
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] detect number but survive also string input

2022-09-10 Thread 'Pascal Jasmin' via Programming
maybeton =: 0&".^:('0'&-: +. 0 -.@-: 0&".) 0&".^:('0'&-: +. 0 -.@-: 0&".) 


 maybeton '3 22r4'

3 11r2

maybeton '3e2 22r4 two'  NB. asking too much

300 5.5 0

maybeton 'two2'

two2


On Saturday, September 10, 2022 at 02:49:30 p.m. EDT, Pawel Jakubas 
 wrote: 





Dear J users,

What is the way to detect number that could be represented as integer,
float, could be negative, could assume scientific notation or rational. Is
there something like isNumber or isString ?
I would like to have something like this:

if. (detect_number i) do.
    process number
else.
    process string

and detect_number to survive inputs
i=: 2
i=: _2
i=: 2r3
i=: 2.
i=: 4.29497e9
i=: 'Two'

Thanks and cheers,
Pawel
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Poll questions: new refcard

2022-08-04 Thread 'Pascal Jasmin' via Programming
By far prefer 1st footnote format.  Grouping together lets you read the 
footnote and find the reference in the main related section quickly.

Colour coding of adv/conj is good.  Wish it was in jqt.

Things seem to generally fit well on page.  If more information/columns in some 
sections would still fit, then that would be better.  But it is fine the way it 
is, and fitting easily is probably most important consideration.




On Thursday, August 4, 2022 at 11:01:45 a.m. EDT, Henry Rich 
 wrote: 





Viktor Grigorov has been busily reworking the old J6.02 reference card.  
The goals of the project are
* show language changes since J6.02
* convert to LaTeX

With the information in LaTeX, it will be easy to change font sizes and 
placement.  The card can then accommodate new changes, and there can be 
multiple versions: perhaps a Large Type version for us old folks.

We need your help!  There are some design questions that need answering 
before Viktor proceeds.  He has created 3 versions of a portion of the card:

https://drive.google.com/file/d/1VwHRkL3I0R6UeqwRtntuMtgcevTk5fS5/view?usp=sharing
 
footnotes by paragraph

https://drive.google.com/file/d/1JRuZDUU3Ij3Cq2AhvsckDu1eWdgb5SUC/view?usp=sharing
 
footnotes at bottom of page in 3 columns

https://drive.google.com/file/d/10KaGw1Mudi3mm-cb5g7SI59RQ-WPvGcm/view?usp=sharing
 
footnotes at bottom of page in 1 column

To take this survey, start by putting the 3 versions into whatever form 
you would normally use them in: either in a window or printed on paper.  
Then answer the questions.

1. In each document, look at a couple of tables with a footnote, and 
refer to the footnotes.  Which layout did you find easiest to use?
a. footnotes at bottom, 1 column
b. footnotes at bottom, 3 columns
c. footnotes below each table

2. What do you think of the size of the main text?
a. too small
b. about right
c. could be smaller

3. What do you think of the size of the footnote text?
a. too small
b. about right
c. could be smaller

4. What do you think of the coloration (indicating part of speech)?
a. don't like it
b. no opinion
c. like it

5. Consider the two tables 'Adverbs' and 'Conjunctions'.  The adverb 
table has a column of menmonic names, the conjunction table does not.  
Are the names helpful?
a. no
b. no opinion
c. yes, for the adverbs
d. yes, and I would like to see names added for the conjunctions
e. yes, and I would like to see a mnemonic name for every primitive

6. In the Foreigns table, would you prefer to see the system-defined 
name in addition to/instead of the m!:n value?
a. m!:n only
b. both
c. system name only

7. Do you have suggestions for formatting?  Write them in.

Please post responses to this Forum (or to me personally if you prefer).

Henry Rich





-- 
This email has been checked for viruses by AVG.
https://www.avg.com

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


Re: [Jprogramming] strange request

2022-07-25 Thread 'Pascal Jasmin' via Programming
,"2^:(2 < #@$) i.3 3 3 2  NB. where ]`(,"2)@.  would fit your first request.


> Also interested in usage of / or folds where the accumulator rank changes over
time (especially if it continues to change after the 1st iteration).

would not be drawn to this model, but when processing a a list of items that is 
meant to return 0 or more items of same shape for each item, (example possible 
future maze moves from a cell), there needs to be a cleanup step to remove 
extra shapes to return full result to a list of items (boxes is easiest code).

But this can also be done with / or fold, by making the function process x as 
the item, and accumulate into an initial i.0 num shape compatible with the 
items.

vitems =: 1 : ' (u@[ , ])/@:(] , i.@0) '(}:@:)

 ,.@#~ vitems ,. 1 2 3 1

1
2
2
3
3
3
1






On Monday, July 25, 2022 at 10:51:16 p.m. EDT, Elijah Stone 
 wrote: 





Have you ever written code using @., as in u`v @. w, where the ranks of the 
results of u and v differ from one another (for a given rank of x/y)?  If so, 
can you post a self-contained snippet?  (Don't worry about being runnable; I 
just want to get a general idea of the code patterns.)

Further stipulations:

- Should not rely on boxing (incidental use of boxes, eg as record types, is ok)

- Equivalent use of explicit control structures or u^:p (for predicate noun or 
verb p) is ok

Also interested in usage of / or folds where the accumulator rank changes over 
time (especially if it continues to change after the 1st iteration).

Thanks!

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


Re: [Jprogramming] Question about the internal working of J

2022-07-24 Thread 'Pascal Jasmin' via Programming
i'll note,

 lr=: 3 : '5!:5 <''y'''

lr i.100

i.100

dyadic $ also "does nothing" until some future time.






On Sunday, July 24, 2022 at 11:17:12 a.m. EDT, Henry Rich 
 wrote: 





For the record, i. 100 does not allocate space for 100 numbers.  It 
creates a virtual noun whose data is an infix of a permanent list of 
ascending integers.

Henry Rich

On 7/24/2022 12:38 AM, Raul Miller wrote:
> Currently i.100 allocates and populates space for 100 integers.
>
> The interpreter would need to become significantly more complex to
> support the "streaming version", but that's conceptually doable (for
> many, but not all cases).
>


-- 
This email has been checked for viruses by AVG.
https://www.avg.com


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


Re: [Jprogramming] local scope or more structured x and y?

2022-07-21 Thread 'Pascal Jasmin' via Programming
I would create a main verb that takes just y as a list of 9 numbers, where 0 is 
an encoding for "unsolved cell" and return a list of 9 numbers that provides a 
template to update a sequence of 9 numbers it was taken from where 0s are 
updated with solved numbers or where a cell can contain a list of possible 
candidates that gets pruned by the function.






On Thursday, July 21, 2022 at 01:27:46 p.m. EDT, 'Viktor Grigorov' via 
Programming  wrote: 





Hey, all,
Looking through the code for my sudoku solver, I think I found the (or a) 
reason why it wasn't working. I keep tracking of all unsolved cells' possble 
values. If a cell gets solves, the cells of its face, row, column get updated 
by just removing the value just solved for using "e.". Each updated cell's 
face, row, column would then too need to be updated, and so on. I'm currently 
doing this with one global variable for the the just solved cell and loops, 
wherein the recursion is: if you remove the, say, "3" from the possibilities of 
"2 3" of one cell in the face or row or column a just solved with a "3" cell, 
the global value should assume the value of "2", within the context of just 
that recurssion, and then assume the "3" again.

This is partially the difficulty with working with at most 2 arguments (of the 
same type), right? What does one usually when encoutering such problem? Pass a 
box with >1 elements and interally assign private variables eachtime, and on 
each necessary recurssion pass everything as ordered list of boxes, or is there 
a way of editting the scope of a to-be-called verb (or part of sentence)?
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread 'Pascal Jasmin' via Programming
it's not a big deal.

a generic polymorphic replacement to @ is:

>: {{if. isNoun 'v' do. u n else. u@v end.}}3
4

 1 >: 2 : 'if. isNoun ''v'' do. u n else. u@v end.' + 3

5

but I think forming trains in form of ([: u n) as an escape when using (`:6) 
formation (more flexible than "real forks") would help more than domain error.  
As example it is possible to do


ari =: 1 : 'if. isNoun ''u'' do. if. (isgerund -.@+.  -: ]) m do. m ar 
else. m end. else.u ar end.'
isgerund =: 0:`(0 -.@e. 3 : ('a =. y (5!:0)';'1')"0)@.(0 < L.) :: 0:

ti =: ari ` ari NB. different from doubleadverb2.ijs: '' is passed to ` . boxed 
non gerund is ar'd ie a:`u

F1 =: 1 : '(ti u) ti (ti) `:6'

doublesum =: + + F1 +

2 doublesum 3

10

 3 + F1 1  NB. `:6 works nicely with m ti verb ti n invocation.

4


F1 is triple modifier that returns fork.  (adverb that returns conjunction) if 
u in conjunction return could be [: then u of adverb could be a monad, making 
the modifier approach to forming trains that much more flexible.

2 3 +(/ F1) 1 2 3

3 4 5
4 5 6














On Tuesday, July 19, 2022 at 02:39:19 p.m. EDT, Henry Rich 
 wrote: 





[:y has the important function of signaling domain error.

Henry Rich

On 7/19/2022 2:35 PM, 'Pascal Jasmin' via Programming wrote:
> I'll add that the fairly recent change of u@n being a constant verb for n is 
> very positive.
>
> Of the approaches I suggested for defining the adverb, the first I prefer.
>
> expecting an adverb to always return a verb is more user friendly than 
> deciding for them.
>
> (>:@1) 3
>
> 2
>
> is good behaviour if the user passes 1 as adverb parameter to (>:@)
>
> 1 (>:@)
>
>> :@1
> Returning a constant verb when provided with a constant or "dynamic" 
> ambivalent (monad+dyad flexibility) execution when provided with a verb is 
> design that will result in fewer edge cases (bugs) when combined with other 
> adverbs that expect, or more importantly, return verbs that tend to be 
> expected by other modifiers.
>
> So. polymorphic return word types from a modifier are design deficient 
> compared to single word types return. Especially considering that a constant 
> verb provides a user intuitive way of obtaining the constant result with the 
> flexibility of using any verb to create a word phrase that can be further 
> processed by modifiers with fewer assumptions about word types.
>
> On a side note, if [:y returned y, there would be additional flexibility in 
> constructing the polymorphic modifier in the form (where ti is ` but turns 
> nouns into gerunds) of {{([: ti >: ti u)(`:6)}}
>
>
> On Tuesday, July 19, 2022 at 12:26:47 p.m. EDT, 'Pascal Jasmin' via 
> Programming  wrote:
>
>
>
>
>
> some options,
>
> if you want your adverb to always produce a verb:
>
>   1 (>:@)
>
>> :@1
> 1 (>:@) 4
>
> 2  NB. increment  on constant of 1 (u/m parameter)
>
>    +: (>:@) 4
>
> 9  NB. increment after applying u (double) to y
>
>
> if you want "polymorphism" in your adverb to return noun result or verb 
> depending on u or m,
>
>
> isNoun =: (0 = 4!:0 ::0:)@:<
>
> 1 {{if. isNoun 'u' do. >: m else. >:@u end.}}
>
> 2
>
> + {{if. isNoun 'u' do. >: m else. >:@u end.}}
>
>> :@+
> 2 + {{if. isNoun 'u' do. >: m else. >:@u end.}}3
>
> 6
>
>
>
> On Monday, July 18, 2022 at 04:03:40 a.m. EDT, Jacques Bailhache 
>  wrote:
>
>
>
>
>
> I define an adverb which gives the successor of its argument :
>
>    advsuc =: 1 : '>: u'
>    1 advsuc
> 2
>
> Then I define an adverb which applies its argument to 1 :
>
>    applyto1 =: 1 : '1 u'
>
> Then I apply it to the adverbial successor :
>
>    advsuc applyto1
> advsuc applyto1
>
> Why isn't it evaluated to 2 ?
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
> --
> For information about J forums see http://www.jsoftware.com/forums.htm


-- 
This email has been checked for viruses by AVG.
https://www.avg.com


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


Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread 'Pascal Jasmin' via Programming
I'll add that the fairly recent change of u@n being a constant verb for n is 
very positive.

Of the approaches I suggested for defining the adverb, the first I prefer.

expecting an adverb to always return a verb is more user friendly than deciding 
for them.

(>:@1) 3

2

is good behaviour if the user passes 1 as adverb parameter to (>:@)

1 (>:@)

>:@1

Returning a constant verb when provided with a constant or "dynamic" ambivalent 
(monad+dyad flexibility) execution when provided with a verb is design that 
will result in fewer edge cases (bugs) when combined with other adverbs that 
expect, or more importantly, return verbs that tend to be expected by other 
modifiers.

So. polymorphic return word types from a modifier are design deficient compared 
to single word types return. Especially considering that a constant verb 
provides a user intuitive way of obtaining the constant result with the 
flexibility of using any verb to create a word phrase that can be further 
processed by modifiers with fewer assumptions about word types.

On a side note, if [:y returned y, there would be additional flexibility in 
constructing the polymorphic modifier in the form (where ti is ` but turns 
nouns into gerunds) of {{([: ti >: ti u)(`:6)}}


On Tuesday, July 19, 2022 at 12:26:47 p.m. EDT, 'Pascal Jasmin' via Programming 
 wrote: 





some options,

if you want your adverb to always produce a verb:

 1 (>:@)

>:@1

1 (>:@) 4

2  NB. increment  on constant of 1 (u/m parameter)

  +: (>:@) 4

9  NB. increment after applying u (double) to y


if you want "polymorphism" in your adverb to return noun result or verb 
depending on u or m,


isNoun =: (0 = 4!:0 ::0:)@:<

1 {{if. isNoun 'u' do. >: m else. >:@u end.}}

2

+ {{if. isNoun 'u' do. >: m else. >:@u end.}}

>:@+

2 + {{if. isNoun 'u' do. >: m else. >:@u end.}}3

6



On Monday, July 18, 2022 at 04:03:40 a.m. EDT, Jacques Bailhache 
 wrote: 





I define an adverb which gives the successor of its argument :

  advsuc =: 1 : '>: u'
  1 advsuc
2

Then I define an adverb which applies its argument to 1 :

  applyto1 =: 1 : '1 u'

Then I apply it to the adverbial successor :

  advsuc applyto1
advsuc applyto1

Why isn't it evaluated to 2 ?
--
For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread 'Pascal Jasmin' via Programming
some options,

if you want your adverb to always produce a verb:

 1 (>:@)

>:@1

1 (>:@) 4

2  NB. increment  on constant of 1 (u/m parameter)

  +: (>:@) 4

9  NB. increment after applying u (double) to y


if you want "polymorphism" in your adverb to return noun result or verb 
depending on u or m,


isNoun =: (0 = 4!:0 ::0:)@:<

1 {{if. isNoun 'u' do. >: m else. >:@u end.}}

2

+ {{if. isNoun 'u' do. >: m else. >:@u end.}}

>:@+

2 + {{if. isNoun 'u' do. >: m else. >:@u end.}}3

6



On Monday, July 18, 2022 at 04:03:40 a.m. EDT, Jacques Bailhache 
 wrote: 





I define an adverb which gives the successor of its argument :

  advsuc =: 1 : '>: u'
  1 advsuc
2

Then I define an adverb which applies its argument to 1 :

  applyto1 =: 1 : '1 u'

Then I apply it to the adverbial successor :

  advsuc applyto1
advsuc applyto1

Why isn't it evaluated to 2 ?
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Tacit definitions of adverbs and conjunctions ?

2022-07-02 Thread 'Pascal Jasmin' via Programming
modifiers ((A)dverbs and (C)onjunctions) can return any form of speech (N V A 
C)  Though only have N or V arguments.


in terms of tacit definitions for modifiers,

thendouble =: +:@:  NB. adverb

For modifier there is one form of explicit definition that can be distinguished 
as semi-tacit:  If your modifier does not use explicit x or y, then it can 
return tacit verbs or modifiers.  If your modifier definition does use y [and 
x] then it is fully explicit returning an explicit verb of specific valence.


thenA =: 1 : 'u@:'  NB. adverb returning adverb
thenAfter =: 2 : 'v@:u'



J playground examples: 

https://jsoftware.github.io/j-playground/bin/html2/#code=thendouble%20%3D%3A%20%2B%3A%40%3A%20%20NB.%20adverb%0AthenA%20%3D%3A%201%20%3A%20'u%40%3A'%20%20NB.%20adverb%20returning%20adverb%0AthenAfter%20%3D%3A%202%20%3A%20'v%40%3Au'%0A%0AexplicitA%20%3D%3A%201%20%3A%200%0Au%20y%0A%3A%0Ax%20u%20y%0A%29%0A%0A2%20%2B%20thendouble%203%0A2%20%2B%20%2B%3AthenA%203%0A2%20%2B%20thenAfter%20%2B%3A%203%0A%0A2%20%2B%20explicitA%20thenAfter%20%2B%3A%203%0A%0A%2B%20explicitA%20thenAfter%20%2B%3A%0A%2B%20%20%2B%3A%20thenA%0A



On Saturday, July 2, 2022, 06:15:29 a.m. EDT, Jacques Bailhache 
 wrote: 





If I understood correctly :
- A monad applies to a noun and produces a noun
- A dyad applies to two nouns and produces a noun
- An adverb applies to a verb or a noun and produces a verb
- A conjunction applies to two verbs or nouns and produces a verb
but does there exist something that produces an adverb or a conjunction ?
In other terms, is it possible to write a tacit definition of an
adverb or a conjunction without using an explicit definition like
myadv =: 1 : '...'
or
myconj =: 2 : '...' ?
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Tiling a matrix to produce a larger matrix

2022-07-01 Thread 'Pascal Jasmin' via Programming
there is

,./ 2 8 $ i. 4 4






On Friday, July 1, 2022, 09:33:48 p.m. EDT, Thomas McGuire 
 wrote: 





I was playing with the Window driver and trying to paint the toucan.bmp to the 
window I created. Expanding on that I wanted to pain a panel of toucan.bmp 
bitmaps to the background. Now I was able to glom together the bitmaps into a 2 
x 2 panel of bitmaps, but it seems I 
should be able to just specify how many rows and columns of matrices I want and 
let J handle the complexity.

I can assign demensions easily and get the structure of what I want through 
boxing. For this I will use a simple square matrix: 

  i. 4 4
0  1  2  3
4  5  6  7
8  9 10 11
12 13 14 15

If I box this I can dial up any table of boxes using shape:

    ’) and getting 
anything close to what I have now.

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


Re: [Jprogramming] Problem with @ (Atop)

2022-06-27 Thread 'Pascal Jasmin' via Programming
Another way to state the equivalence of @, in linear form rather than tacitly

u"v [x] v y






On Monday, June 27, 2022, 03:30:35 p.m. EDT, 'Pascal Jasmin' via Programming 
 wrote: 





You have brought up a bug in dicitionary, that has survived to J6.02

@: has the correct analogous quoted linear definition.

the actual equivalence is

1 2 3 ([: +/ *)"* 4 5 6

4 10 18

or,

([: u v)"v




On Monday, June 27, 2022, 08:21:47 a.m. EDT, Jacques Bailhache 
 wrote: 





According to https://www.jsoftware.com/help/dictionary/d620.htm :
x u@v y ↔ u x v y
But :
  1 2 3 +/@* 4 5 6
4 10 18
  +/ 1 2 3 * 4 5 6
32
Why does it give different results ?
--
For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] Problem with @ (Atop)

2022-06-27 Thread 'Pascal Jasmin' via Programming
You have brought up a bug in dicitionary, that has survived to J6.02

@: has the correct analogous quoted linear definition.

the actual equivalence is

1 2 3 ([: +/ *)"* 4 5 6

4 10 18

or,

([: u v)"v




On Monday, June 27, 2022, 08:21:47 a.m. EDT, Jacques Bailhache 
 wrote: 





According to https://www.jsoftware.com/help/dictionary/d620.htm :
x u@v y ↔ u x v y
But :
  1 2 3 +/@* 4 5 6
4 10 18
  +/ 1 2 3 * 4 5 6
32
Why does it give different results ?
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Fork does not work

2022-06-22 Thread 'Pascal Jasmin' via Programming
appliedto is an adverb. (happens to always return true, and select only right 
hand of gerund argument)
mult is a monad that returns a gerund 


Your last example is

V A V which gets parsed as (V A) V

But appliedto needs a gerund argument to not be a domain error.

(mult appliedto) is an error.  mult is a verb, not a gerund.


(] * +:) gives the result you want.



On Wednesday, June 22, 2022, 07:36:08 a.m. EDT, Jacques Bailhache 
 wrote: 





Hi,
I am learning J and I don't understand something about forks.
According to https://www.jsoftware.com/help/primer/fork.htm :
  (f g h) y    evaluates as    (f y) g (h y)
I define this dyad :
  appliedto =: @.(]@1)
and this monad :
  mult =: 3 : ']`(* & y)'
Here is an example using these functions :
  (mult 10) appliedto (+: 10)
200
Normally it should be equivalent to this fork but it does not work :
  (mult appliedto +:) 10
|domain error
|  (mult    appliedto+:)10
Do you understand why I get this error ?

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


Re: [Jprogramming] CVA (was: unwind protect)

2022-05-01 Thread 'Pascal Jasmin' via Programming
natural being the binding that would occur if modifier parameters were present.

ACV is natural.
AVC is also not defined.  Natural: A(VC)
VCA is not horribly unnatural. (VC)A allows an escape for the more natural, but 
would be more cumbersome to do definition (V(]: C A))
CVA as natural (CV)A just saves much more parentheses.  It is an adverb that 
can extend to right so:

CVACA automatically becomes (CVA)CA instead of needing ((CV)A)CA


CV(].A) accomplishes your recommendation without seeming that cumbersome.  
There is also the super flexible :
VasC =: 1 : '[. u ].'
then both CCA and ACC can have their middle C set as V VasC.  or your request 
can also be accomplished as C([. V ].)A


Since both AVC and CVA are undefined, we could make at least one of them the 
natural definition.  AV~C could fill your original proposal, but I think if 
I/we can only have 1 of the 2 natural definitions, I'd pick AVC:  Lets a series 
of pairable VC CV sequences get autopaired with ]:CV or ]:VC as leading 
"triplet".

A problem with the modifier trains is that AA is not one in order to permit AAV

CAA and AAA are natural.

AAC could be defined naturally as uAACv

CVA as an adverb (natural (CV)A) is more convenient than a "weird" conjunction, 
because we need more adverb forms for trainability.
Forcing (AA) or AA]: to make a single adverb (when only one is allowed in 
modifier train slot, and so must be reduced to one) is cumbersome, and filling 
undefined modifier 3 trains in their natural adverb preferred form solves 
cumbersomeness in the more common trains.


One of the reasons I hate AC so much is that 2-length modifier trains are 
"precious"  They rule 4-length, 6-length trains too.  Overly esoteric 
definitions should be implemented with 3-length trains.


On Sunday, May 1, 2022, 11:07:59 p.m. EDT, Elijah Stone  
wrote: 





Why is CVA -> (CV)A more natural?  Convention with trains is for the parser to 
make them as long as possible, since you can add the parens manually if you 
need the shorter train.  CVA should be consistent with CCA and CVC.

It's true there are multiple ways to express the same thing; there always are.

Making AC consistent with CA is interesting, but since 2-trains are inherently 
asymmetric anyway (except CC), it seems less important.  And changing AC 
breaks compatibility, whereas adding CVA does not.

On Sun, 1 May 2022, 'Pascal Jasmin' via Programming wrote:

> There is a more "obvious" interpretation of CVA
>
> (CV)A is the more natural extension of uCV A.  (C(VA)) would be a possibility 
> that is less obvious.
>
> Your proposal can be accomplished with
>
> CV(].A)  NB. also allows CV([.A) for flexibility of A binding.
>
> The current interpretation of AC could be accomplished with
>
> (AC[.) a:
>
> which would let AC be the "more natural consistent with CA" be the 
> conjunction uACv
>
>
>
>
> On Sunday, May 1, 2022, 01:54:06 a.m. EDT, Elijah Stone  
> wrote: 
>
>
>
> (Side-note: how come CCA and CVC are legal, but not CVA?  I think CVA should 
> be uCv V vA.  That seems fairly obvious and consistent, and it would simplify 
> the above definition of under_lock.  AVC should be analogous.  I think this 
> was proposed this a while ago but nothing came of it.)
>
> -E

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

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


Re: [Jprogramming] unwind protect

2022-05-01 Thread 'Pascal Jasmin' via Programming
A J approach where,

v is a monadic resource acquisition function (file open, acquire lock) with a 
defined inverse whose result we normally don't care about (want the result of 
u).  v inv should raise an error instead of return an error code.  there are 2 
options for y argument to v inv :

 v inv v y (independent of [x] u v y)  NB. open file :. close file as example
 
or

v inv [x] u v y  NB. read file :. write file where u changes file contents.  
write file as inverse to read file is dyadic (legal inverse), and so function 
is incorrect for purposess of read write duality, but such monadic :. dyadic 
inverse functionality is easy to write.  An interesting concept about duality, 
rather than the "inversality" term that duals in J as used for is:  :. (dual 
definition) is an alternative to gerunds where a modifier can access (any 
defined) the dual as a 2nd parameter included in u or v, where inverses reflect 
the core J library, but with user verbs, or some of these locks, 
acquire/release is close to invesality, there's no conceptual limit on defining 
a duality related to modifer purpose. 

u for initial simplicity is dyadic

e is error + cleanup (v inv) function that will pickup error in either u or (v 
inv):  (13!:12 (13!:8) 13!:11 [ v inv@]) 

but where e can be invoked on error of v u or v inv.

e =: ( :: (13!:12@[(13!:8)13!:11 ))


up1=:  2 : ' ( v inv(@])e ] u ( :: ( (13!:12@[ (13!:8) 13!:11)@@(v inv@])) 
)) v e '

and then for u ambivalence

uped =: (@]) up1 ]: : up1 


to show the 3 possible error "positions" and no error behaviour


  2 +up1(-&> ::] :.((-@<)@(1!:2&2))) 3

_3

|domain error

| 2 +up1(-&> ::] :.((-@<)@(1!:2&2)))3

Error in v inv (-@< after display) display shows that v was executed: _3



2 +up1(- :. (1!:2&2) ) '3'

|rank error

| 2 +up1(- :.(1!:2&2))'3'

Error in v (-)  bug somewhere (perhaps even my code) that makes this a rank 
error instead of domain error.  No display shows v inv did not execute.



   2 +up1(< :. (1!:2&2) ) 3

┌─┐

│3│

└─┘

||domain error

| 2 +up1(< :.(1!:2&2))3

Error in u.  v inv (display) still executes when u causes error.

2 +up1(- :. (1!:2&2) ) 3

_3

_1

No error. v inv executes return value is x u v y (_1)


   +:uped(- :.(1!:2&2))3

_3

_6








On Sunday, May 1, 2022, 07:52:05 a.m. EDT, Hauke Rehr  
wrote: 





which seems to have been done before
or came up independently

in D, you have slightly more fine-grained options

scope(exit){}


scope(success){}
scope(failure){}



a spontaneous reaction:

In J, I’d like to use generators like
fileworker =. workfile thatone
'exitstatus result' =. verb_using_file&.fileworker arg_of_verb
or
memlocker =. lockmem mutex
'exitstatus result' =. atomic_verb&.memlocker arg_of_verb

[do we even need exitstatus?]

one could even make them generate adverbs
but using &. makes the intent clear
so I’d prefer not adding too much syntactic
sugar – but as always, there are different
tastes and digestive systems (called minds) …

so the argument should be passed and the cleanup
assigned as the obverse, potentially supplementing
the result with an exit status value/error code

would that interfere with your ideas?


Am 01.05.22 um 07:54 schrieb Elijah Stone:
> an idea worth stealing

-- 
--
mail written using NEO
neo-layout.org

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


Re: [Jprogramming] CVA (was: unwind protect)

2022-05-01 Thread 'Pascal Jasmin' via Programming
There is a more "obvious" interpretation of CVA

(CV)A is the more natural extension of uCV A.  (C(VA)) would be a possibility 
that is less obvious.

Your proposal can be accomplished with

CV(].A)  NB. also allows CV([.A) for flexibility of A binding.

The current interpretation of AC could be accomplished with

(AC[.) a:

which would let AC be the "more natural consistent with CA" be the conjunction 
uACv




On Sunday, May 1, 2022, 01:54:06 a.m. EDT, Elijah Stone  
wrote: 



(Side-note: how come CCA and CVC are legal, but not CVA?  I think CVA should be 
uCv V vA.  That seems fairly obvious and consistent, and it would simplify the 
above definition of under_lock.  AVC should be analogous.  I think this was 
proposed this a while ago but nothing came of it.)

-E

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


Re: [Jprogramming] unwind protect

2022-05-01 Thread 'Pascal Jasmin' via Programming
~~ can be used with even a tacit function.  Makes u dyad only.

I want to avoid using AC hoping it gets changed, but:

1 : ' u@]~~ : u '  or simpler 1 : ' u@] : u '

The ~~ form lets dyadic u access original y as x, and any processed y as y.






On Sunday, May 1, 2022, 04:07:19 a.m. EDT, Elijah Stone  
wrote: 





On Sat, 30 Apr 2022, Elijah Stone wrote:

> (is it possible to avoid duplication of the monadic and dyadic cases?)

(hmm, I have an ugly solution: preprocess u and v into x and x in the 
dyadic case st u y and v y always do the right thing.  Slightly less abusive 
to the notation but no less ugly would be to make u'' and v'' always do the 
right thing.  But I have no pretty solution.)

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


Re: [Jprogramming] general fold

2022-04-23 Thread 'Pascal Jasmin' via Programming
fold may not be the right approach

1 ( 3 2 $ 1 2 3 4 5 6)} 10 10 $ 0






On Saturday, April 23, 2022, 02:02:10 p.m. EDT, Pawel Jakubas 
 wrote: 





Dear J enthusiast,

I try to play with fold functionality F...
and here solve more general cases, so when the accumulator structure is
different from the list structure that is iterated.

To be concrete let's say we have the array, A, and a list of 2-elem
vectors, vec,
which institute coordinates (x,y) which I want to update in A.
```
A=: 10 10 $ 0
]vec=: 3 2 $ 1 2 3 4 5 6
1 2
3 4
5 6
```
Now, I can of course solve this recursively, eg:
```
fold=: 4 : 0
'r c' =. ,"0 $ x
if. (r=1) do.
  'x0 y0'=. {. x
  1 (<(x0),(y0)) } y
else.
    'x0 y0'=. {. x
  y1=.1 (<(x0),(y0)) } y
  (}. x) fold y1
end.
)
  vec fold A
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
```

How to start with A, use vec as iterator list in one of folds F.. and end
up with updated A as above?
Thanks in advance!
Cheers,
Pawel Jakubas
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] lex / dev question

2022-04-21 Thread 'Pascal Jasmin' via Programming
> (].~)@:

It is the CC train.  The @: will bind to u@:v

(].~) is CA  (so still part of overall CC train (CA)C is CC)

]. ignores u, and so (].~) is v~






On Thursday, April 21, 2022, 10:35:41 a.m. EDT, Michal Wallace 
 wrote: 





Thanks, Elijah! This was very helpful.

I think I was sort of hallucinating that the mere presence of [. and ].
would change the meaning of the entire train,
the way the mere presence of  u and v changes the meaning of a direct
definition, but of course that's not the case.

I am going to have to meditate on (].~)@: for a while.. I see it, but I
don't quite believe it. :D

Thanks!

On Thu, Apr 21, 2022 at 6:30 AM Elijah Stone  wrote:

> On Thu, 21 Apr 2022, Michal Wallace wrote:
>
> > I then thought that replacing u => [. and v => ]. would let me remove
> the
> > double curlies, but clearly this is the wrong idea:
> >
> >  AA =: ([. @: ].) ]. ]
> >  _: AA (3 AT) ;/i.10
> > +-+-+-+-+-+-+-+-+-+-+
> > |0|1|2|3|4|5|6|7|8|9|
> > +-+-+-+-+-+-+-+-+-+-+
> >
> > I don't really understand what it's doing but I'm (mistakingly?)
> imagining
> > that it's a fork.
>
> Let's break it down.  Starting inside the parens: ([. @: ].) is a train of
> three conjunctions; that is a conjunctive fork.  The rule is: u(C0C1C2)v
> is
> (uC0v)C1(uC2v).  C0 is [., C1 is @:, and C2 is ]. .  u[.v is u (by
> definition), and u].v is v (by definition).  So u([. @: ].)v is
> (u[.v)@:(u].v), which is u@:v.  Which means that [. @: ]. is just an
> obfuscated way of writing @:, similar to to the verb fork [ + ] .
>
> That means your AA definition is equivalent to @: ]. ] .  @: ]. ] is also
> a
> conjunctive fork.  It is not CCC, but CCV; the right tine of the fork is
> constant.  This is analogous to an NVV verb fork, where the left tine is
> constant.  The rule here is: u(C0C1V2)v is (uC0v)C1V2.  C0 is @:, C1 is
> ].,
> and V2 is ] .  So, regardless of what u and v are, we will get (u@:v) ].
> ],
> which is just ] .
>
> A conjunctive fork _is_ a fork, but there is no reason to believe it will
> _produce_ a verb fork.
>
> > If it were a fork with ] on the right, I think I should be able to
> rewrite
> > it like so:
> >
> >  AA =: ].~ ([. @: ])
> >
> > But this gives a syntax error Why?
>
> This is very close to working.  The issue is that when producing trains,
> the
> parser tries to eat as many terms as it can.  So for instance, in a
> regular
> verb train, it could have been defined that f g h is a two-level hook,
> equivalent to f (g h).  But then we wouldn't be able to make forks.  So we
> say
> that a 3-train will be formed whenever there are at least 3 terms
> available;
> and we will only form a 2-train when we have no other choice.  Your
> definition
> is ]. ~ ([. @: ].), that is CAC; and no meaning has yet been assigned to
> CAC,
> so it is a syntax error.  But you want (CA)C.  Parenthesizing as (].~) ([.
> @:
> ].) gives a result that works!  (And this is effectively the same as the
> solution of (].~) @: I gave; I missed this before, when I was skimming.)
>
>
> > So okay, if I just put ] back in on the left:
> >
> >  AA =: ] ].~ ([. @: ].)
> >  _: AA (3 AT) ;/i.10
> > _
>
> Now you are running into grouping issues again.  I don't quite understand
> the
> parsing rules for longer trains--it is simply left-to-right in simple
> cases,
> but more interesting in other cases; pascal has a wiki article about
> it--but
> in this case it does work out nicely left to right.  We can ask the repl
> how
> this sentence parenthesises:
>
>    AA =: ] ].~ @:
>    AA
> (] ]. ~)@:
>
> We had VCAC, and it was grouped as (VCA)C.  VCA is an adverb; so the
> sentence
> as a whole is AC, which is also an adverb; not a conjunction.  So it is
> not
> surprising that you got nonsense results here :)  Left as an exercise to
> you
> is to figure out exactly why you get the result that you do.
>
> In general, I suggest referring to the table at
> https://code.jsoftware.com/wiki/Vocabulary/fork#invisiblemodifiers at
> frequent
> intervals, and querying parenthesisation at the repl.
>
>  -E
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] lex / dev question

2022-04-20 Thread 'Pascal Jasmin' via Programming
the removing y part -semi tacit

2 :  'u@:v v ]'

I don't think there is a "modifier train" expression that would be full tacit.






On Thursday, April 21, 2022, 01:42:48 a.m. EDT, Michal Wallace 
 wrote: 





I want to write this tacitly:

    AA =: {{ (u v y) v y }}

For context, I tend to use it to *A*pply monad u *A*t at a location
specified by ambivalent verb v.

  AT =: {{ m&{:: : (<@[ m} ]) }}
  3 AT ;/i.10
3
    _ (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|_|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+

  _: AA (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|_|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+


My main question is "how do I write AA tacitly?", but I'd also like to
present my (incorrect) thinking here in hopes that someone can fix it. :)

I first translated it into a fork inside a direct definition, and that
works fine:

  AA =: {{ ((u @: v) v ]) }}
  _: AA (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|_|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+

I then thought that replacing u => [. and v => ]. would let me remove the
double  curlies, but clearly this is the wrong idea:

  AA =: ([. @: ].) ]. ]
  _: AA (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|3|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+

I don't really understand what it's doing but I'm (mistakingly?) imagining
that it's a fork.

If it were a fork with ] on the right, I think I should be able to rewrite
it like so:

  AA =: ].~ ([. @: ])

But this gives a syntax error Why?

So okay, if I just put ] back in on the left:

  AA =: ] ].~ ([. @: ].)
  _: AA (3 AT) ;/i.10
_

Clearly my idea that [. and ]. mean "tacit u and v" is wrong.

Can anyone help me correct my thinking?

Thanks!

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


Re: [Jprogramming] Help required

2022-04-08 Thread 'Pascal Jasmin' via Programming
This approach is efficient because it is checking the "2 halves" of the 6char 
list on existence in the 3 char list, instead of permuting all combinations of 
3-list items.






On Friday, April 8, 2022, 10:32:51 a.m. EDT, Henry Rich  
wrote: 





   l =. 'abc','def',:'ghi'
   l
abc
def
ghi
   r =. 'abceee','defabc','mmmxxx','abcdef',:'ghidef'
   r
abceee
defabc
mmmxxx
abcdef
ghidef

   l (] #~ [: *./"1  (e.~   2 3&$"1)) r
defabc
abcdef
ghidef

Henry Rich


On 4/8/2022 10:21 AM, Richard Donovan wrote:
> Hi J programmers
>
> I need help to discover the most efficient way of doing the following :-
>
> I have two tables, on of n three-character items, and a second of m 
> six-character items such as…
>
> abc,def,ghi
>
> abceee,defabc,mmmxxx,abcdef,ghidef
>
> I need to know which six-character items can be composed of any two 
> concatenated three-character items, so in the above example the required 
> output would be
>
> defabc,abcdef,ghidef
>
> There may be many thousands of entries in each tables, so an efficient 
> algorithm is required!
>
> Thanks in advance
>
> Richard Donovan
>
> --
> For information about J forums see http://www.jsoftware.com/forums.htm


-- 
This email has been checked for viruses by AVG.
https://www.avg.com


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


Re: [Jprogramming] Verb concatenation

2022-04-02 Thread 'Pascal Jasmin' via Programming
want to draw attention to a bug in the jplayground using a variation of your 
script

https://jsoftware.github.io/j-playground/bin/html/emj.html#code=%20foo0%3D%3A%203%20%3A%20'0'%0D%0A%20%20foo1%3D%3A%203%20%3A%20'1'%0D%0A%20%20foo2%3D%3A%203%20%3A%20'2'%0D%0A%20%20foo3%3D%3A%203%20%3A%20'3'%0D%0A%20%20allfoo%3D%3A%20foo0%2Cfoo1%2Cfoo2%2Cfoo3%0D%0A%20%20allfoo%20''%0D%0A%20%20allfoo%3D%3A%20foo0%2Cfoo1%0D%0A%20%20allfoo%3D%3A%20allfoo%20f.%60%2C%60foo2%60%2C%60foo3%60%3A6%20%0D%0A%20%20allfoo


allfoo does not return a value (verb)

and resetting/refreshing playground is needed to get assignments to work.

I don't think it is a bug though.

scoped recursion is achieved through names.  The use of f. to do what you 
intended (no parentheses needed, btw) is a good use of f. to easily "solve 
everything".

another playground link, that provides an alternate solution

  allfoofinal=: allfoo,foo2,foo3

https://jsoftware.github.io/j-playground/bin/html/emj.html#code=c%20foo0%3D%3A%203%20%3A%20'0'%0D%0A%20%20foo1%3D%3A%203%20%3A%20'1'%0D%0A%20%20foo2%3D%3A%203%20%3A%20'2'%0D%0A%20%20foo3%3D%3A%203%20%3A%20'3'%0D%0A%20%20allfoo%3D%3A%20foo0%2Cfoo1%2Cfoo2%2Cfoo3%0D%0A%20%20allfoo%20''%0D%0A%20%20allfoo%3D%3A%20foo0%2Cfoo1%0D%0A%20%20allfoofinal%3D%3A%20allfoo%2Cfoo2%2Cfoo3%0D%0A%20%20allfoofinal



On Saturday, April 2, 2022, 01:42:43 p.m. EDT, Devon McCormick 
 wrote: 





Hi,
I have a group of monadic verbs for which I want the concatenated result,
e.g.
  foo0=: 3 : '0'
  foo1=: 3 : '1'
  foo2=: 3 : '2'
  foo3=: 3 : '3'
  allfoo=: foo0,foo1,foo2,foo3
  allfoo ''
0 1 2 3

So *allfoo* does what I want.  However, my actual set of verbs is longer
than this so I broke the assignment of *allfoo* into two pieces for
readability:
  allfoo=: foo0,foo1
  allfoo=: allfoo,foo2,foo3
  allfoo
allfoo , foo2 , foo3
  allfoo ''
|stack error: foo3
|allfoo[0]

I have inadvertently introduced infinite recursion.  Clearly I'm missing
something thinking I can concatenate verbs like I can concatenate nouns.

This gives me a result that performs as expected but looks bad:
  allfoo=: foo0,foo1
  allfoo=: (allfoo f.),foo2,foo3
  allfoo''
0 1 2 3
  allfoo
(3 : (,'0') , 3 : (,'1')) , foo2 , foo3

Any suggestions on how to break the assignment into multiple lines?

Thanks,

Devon



-- 

Devon McCormick, CFA

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


Re: [Jprogramming] RFC: unicode

2022-03-19 Thread 'Pascal Jasmin' via Programming
The proposed semantics (It probably would help everyone if there was a shorter 
retelling of the semantics, even assuming the reader was able to skim through 
most of it.)

there is a UCS-1 that is different from J's utf8?  Is UCS-1 actually an update 
of utf8 that has differences?

Does your proposal's main concern is some ability to handle misformed 
unicode/utf8 sequences?  If handling means turn that "character" into null, how 
do you guarantee the malformation wasn't a missing byte, and that the rest of 
the "stream" would be well formed (and the intent of message) if that missing 
byte could be guessed instead of consuming "the first byte of next character".

The main idea may instead be that if there is malformed unicode, then instead 
of figuring out some result, whoever sent this garbage should be notified that 
it is garbage.

This sounds like a C library should exist that prescreens whatever 
malformations you are looking for to determine malformations.

I believe you are also saying that UCS-1 or utf8 are ubiquitous in the outside 
world.  I can only understand the appeal as one of space/bandwidth saving.  A 
better space saving encoding is lempel-ziv (zip) or better compression on 
unicode4.

I second Bill's question of is there an example of unicode4 not full containing 
a character?  If such an example exists, then there must be some unicode8 
proposal that J should adopt such that such terrorism can be dealt with in the 
simplest way.

I suspect this is all about the condition of uninterpretable expectations of 
unicode4 formations.  This sounds like the application calling your function 
may really want to communicate a tablex4 sequence of bytes, and if so or even 
if not, asking them to convert to the sequence of bytes that they mean or 
should mean instead of unicode is a perfect solution to your J code being in 
control of what to do, though 3: may be the exact match to what they would 
change.

If instead it is about calling UCS-1 APIs from J, and J doesn't have that exact 
representation, then a dll/C library might be suitable to convert from unicode4 
to UCS-1, and/or implement compression/decompression functions that make every 
side that can use a C library able to communicate in the better compressed and 
less ambiguous format. 






On Saturday, March 19, 2022, 03:13:01 p.m. EDT, Elijah Stone 
 wrote: 





Promotion treats text as ucs-n.  ": treats text as utf-n.

And again: what is wrong with my proposed semantics?  I explained why I 
think they are better.  I have not heard a contrary argument.

On Sat, 19 Mar 2022, bill lam wrote:

> Further clarification, J language itself knows nothing about unicode
> standard.
> u: is the only place when utf8 and utf16 etc are relevant.
>
>
> On Sat, 19 Mar 2022 at 10:17 PM bill lam  wrote:
>
>> I think the current behavior of u: is correct and intended.
>> First of all, J utf8 is not a unicode datatype, it is merely a
>> interpretation of 1 byte literal.
>> Similarly 2 byte and 4 byte literal aren't exactly ucs2 and uft32, and
>> this is intended.
>> Operation and comparison between different types of literal are done by
>> promotion atom by atom. This will explain the results that you quoted.
>>
>> The handling of unicode in J is not perfect but it is consistent with J
>> fundamental concepts such as rank.
>>
>> On Sat, 19 Mar 2022 at 7:17 AM Elijah Stone  wrote:
>>
>>>    x=: 8 u: 97 243 98      NB. same as entering x=: 'aób'
>>>    y=: 9 u: x
>>>    z=: 10 u: 97 195 179 98
>>>    x
>>> aób
>>>    y
>>> aób
>>>    z
>>> aób
>>>
>>>    x-:y
>>> 0
>>>    NB. ??? they look the same
>>>
>>>    x-:z
>>> 1
>>>    NB. ??? they look different
>>>
>>>    $x
>>> 4
>>>    NB. ??? it looks like 3 characters, not 4
>>>
>>> Well, this is unicode.  There are good reasons why two things that look
>>> the same might not actually be the same.  For instance:
>>>
>>>    ]p=: 10 u: 97 243 98
>>> aób
>>>    ]q=: 10 u: 97 111 769 98
>>> aób
>>>    p-:q
>>> 0
>>>
>>> But in the above case, x doesn't match y for stupid reasons.  And x
>>> matches z for stupider ones.
>>>
>>> J's default (1-byte) character representation is a weird hodge-podge of
>>> 'UCS-1' (I don't know what else to call it) and UTF-8, and it does not
>>> seem well thought through.  The dictionary page for u: seems confused as
>>> to whether the 1-byte representation corresponds to ASCII or UTF-8, and
>>> similarly as to whether the 2-byte representation is coded as UCS-2 or
>>> UTF-16.
>>>
>>> Most charitably, this is exposing low-level aspects of the encoding to
>>> users, but if so, that is unsuitable for a high-level language such as j,
>>> and it is inconsistent.  I do not have to worry that 0 1 1 0 1 1 0 1 will
>>> suddenly turn into 36169536663191680, nor that 2.718 will suddenly turn
>>> into 4613302810693613912, but _that is exactly what is happening in the
>>> above code_.
>>>
>>> I give you the crowning WTF (maybe it is not so surprising at this
>>> point...):
>>>
>>>    x;y;x,y  

Re: [Jprogramming] RFC: unicode

2022-03-18 Thread 'Pascal Jasmin' via Programming
3 u: 8 u: 97 243 98

97 195 179 98

3 u: 10 u: 97 243 98

97 243 98

the key takeaway is that utf8 is flakey if you ever want your numbers back.  
Converting utf8 (literal) to unicode or unicode4 prior to counting/appending 
them with other unicode should stay sane(?)

3 u: 7 u: 8 u: 97 243 98

97 243 98




On Friday, March 18, 2022, 09:33:16 p.m. EDT, Elijah Stone 
 wrote: 





1. As I demonstrated, j does _not_ treat its strings as though they are 
utf8-encoded, but rather as a bizarre hodge-podge of utf8 and 'ucs-1'. 
This is not a documentation problem.  Again:

    x=: 8 u: 97 243 98
    y=: 9 u: x
    NB. x is a perfectly good utf8-encoded string
    datatype x
literal
    x
aób
    NB. y is a perfectly good ucs4-encoded string
    datatype y
unicode4
    y
aób
    NB. gobbledygook
    x,y
aóbaób

2. As a programmer, I don't see why I should care how strings are 
encoded, unless I am specifically dealing with external data which is 
mis-encoded.

3. And if the strings really are utf8, then indices should be in code 
points, not code units, and invalid utf8 should be impossible to 
construct.

On Sat, 19 Mar 2022, chris burke wrote:

> I think the correct view is that J text strings are in utf8 and the
> programmer should handle it.
>
> This does mean that some sequences of bytes that are not uft8 look odd in
> the terminal.
>
> Perhaps the documentation should be improved?
>
> On Sat, Mar 19, 2022 at 8:48 AM Elijah Stone  wrote:
>
>> An easy counter-argument to all of this runs as follows: I have proposed a
>> breaking change, but there is a great deal of 'break', and not much
>> 'change' to show for it.  I will attempt to head this off peremptorily:
>>
>> Attempting to do text-processing without considering unicode is like
>> trying to do math before russel, godel, et al.  It is necessary to
>> consider very carefully what we are doing, whether it is ok to do it, and
>> if so why.  The ultimate conclusion is inevitably that 99% of what we are
>> doing was fine, but 1) the existence of sound underpinnings _is_
>> significant; and 2) that 1% does matter.  J's text handling capabilities
>> are unsound, and this manifests in the form of inconsistencies, as
>> demonstrated.
>>
>>  -E
>>
>> On Fri, 18 Mar 2022, Elijah Stone wrote:
>>
>> >  x=: 8 u: 97 243 98      NB. same as entering x=: 'aób'
>> >    y=: 9 u: x
>> >    z=: 10 u: 97 195 179 98
>> >    x
>> > aób
>> >    y
>> > aób
>> >    z
>> > aób
>> >
>> >    x-:y
>> > 0
>> >    NB. ??? they look the same
>> >
>> >    x-:z
>> > 1
>> >    NB. ??? they look different
>> >
>> >    $x
>> > 4
>> >    NB. ??? it looks like 3 characters, not 4
>> >
>> > Well, this is unicode.  There are good reasons why two things that look
>> > the same might not actually be the same.  For instance:
>> >
>> >    ]p=: 10 u: 97 243 98
>> > aób
>> >    ]q=: 10 u: 97 111 769 98
>> > aób
>> >    p-:q
>> > 0
>> >
>> > But in the above case, x doesn't match y for stupid reasons.  And x
>> > matches z for stupider ones.
>> >
>> > J's default (1-byte) character representation is a weird hodge-podge of
>> > 'UCS-1' (I don't know what else to call it) and UTF-8, and it does not
>> > seem well thought through.  The dictionary page for u: seems confused as
>> > to whether the 1-byte representation corresponds to ASCII or UTF-8, and
>> > similarly as to whether the 2-byte representation is coded as UCS-2 or
>> > UTF-16.
>> >
>> > Most charitably, this is exposing low-level aspects of the encoding to
>> > users, but if so, that is unsuitable for a high-level language such as
>> j,
>> > and it is inconsistent.  I do not have to worry that 0 1 1 0 1 1 0 1
>> will
>> > suddenly turn into 36169536663191680, nor that 2.718 will suddenly turn
>> > into 4613302810693613912, but _that is exactly what is happening in the
>> > above code_.
>> >
>> > I give you the crowning WTF (maybe it is not so surprising at this
>> > point...):
>> >
>> >    x;y;x,y                NB. pls j
>> > ┌───┬───┬───┐
>> > │aób│aób│aóbaób│
>> > └───┴───┴───┘
>> >
>> > Unicode is delicate and skittish, and must be approached delicately.  I
>> > think that there are some essential conflicts between unicode and j--as
>> > the above example with the combining character demonstrates--but also
>> that
>> > pandora's box is open: literal data _exists_ in j.  Given that that is
>> the
>> > case, I think it is possible and desirable to do much better than the
>> > current scheme.
>> >
>> > ---
>> >
>> > Unicode text can be broken up in a number of ways.  Graphemes,
>> characters,
>> > code points, code units...
>> >
>> > The composition of code units into code points is the only such
>> > demarcation which is stable and can be counted upon.  It is also a
>> > demarcation which is necessary for pretty much any interesting text
>> > processing (to the point that I would suggest any form of 'text
>> > processing' which does not consider code points is not actually
>> processing
>> > text).  Therefore, I suggest that, at 

Re: [Jprogramming] Report on the J wiki meeting of January 27, 2022

2022-03-14 Thread 'Pascal Jasmin' via Programming
I'll remind "the world" that a dictionary implementation has been published: 
https://github.com/Pascal-J/kv

I'll defend it as being the most J friendly implementation for having 
functional access + manipulation features, it further has, through the kvO 
adverb, the ability to J-optimize access at the expense of future manipulation. 
 J is mostly considered a tool for structuring information prior to 
querying/subsetting it.  A locale based state-oriented dictionary approach 
makes it overhead/difficult to extract information subsets, and adds object 
management difficulties on top of the access.


To paraphrase Hitchhiker's galaxy, "first God/J/Ken created OOP and locales, 
and everyone agreed that was terrible"



On Monday, March 14, 2022, 10:01:28 a.m. EDT, Michal Wallace 
 wrote: 





It's true that dictionaries aren't really a "fundamental" data type, since
they're easy to implement atop arrays.
But I think for a lot of people, they've become a fundamental "thinking
type"...

I think jan-pieter's requirements list is a good start. I would add:

- nice syntax for constructing the mapping as a list of pairs rather than a
pair of lists.
- nice syntax for traversing nested structures
- ability to write "accessor" methods that intervene
- ability to chain dictionaries together (to give search paths like locales
have)

I've mentioned before that I think there could be a real benefit to having
a nested namespace model for locales.
I think it would be nice if, when you imported a module from path
'foo/bar/baz', you could trust that it would load
something into a namespace that had a corresponding nested path name.

That does raise the question about how to make navigating a path play nice
with J's right-to-left syntax.

In other words, I think locales already do much of what we want for
dictionaries, but I'm not sure if they're implemented
in terms of hashtables. (AFAIK, k3 doesn't even use hash tables for
dictionaries. It's always just a linear lookup.)

One thing that is missing is the ability to have arbitrary (non-identifier,
or even non-string) keys, or the ability to fetch multiple values at once.

In j-kvm (that console library I've been working on),  I implemented a
simple verb that I really wish had a standard name in J:

of =: {{ (x,'__y')~ [ y }}"1 0

My ui widgets have two separate flags related to display: V__w indicates
that w is visible, and R__w indicates that it's in need of a refresh.
So when it comes time to render an application with list of widgets W: I
can select both flags at once from all the widgets:

render =: {{
  for_w. W #~ *./'VR' of "0 W do.
    NB. render w
  end. }}



On Mon, Jan 31, 2022 at 1:27 PM Henry Rich  wrote:

> I have looked into this quite a bit.  I am not convinced that Dictionary
> is a fundamental datatype like number or letter, or that the current
> symbol support is deficient.  That makes the first questions What is a
> Dictionary? and Where can a Dictionary be used in J?
>
> The use case that would be important to me is a key-value store, aka
> associative memory, where the Dictionary remember keys and values and
> later returns a value when presented with the key. This feels to me like
> a package written in J rather than a J primitive.  A Dictionary would be
> a numbered locale.  The place where I could see added support inside J
> would be in adding to and deleting from hashtables, specifically ones
> created/used by m .
>
> I invite proposals on what a Dictionary package needs to do.  I have
> done this before, and Jan-Pieter Jacobs responded with a package.
> Quoting from his message of 20210327:
>
> *** QUOTE
>
> install'github:jpjacobs/types_dict@main'
>
> (except on (my) android, where github installs don't seem to work, neither
> in the Gui version JA nor on the commandline via termux)
>
> It is pretty simple in use, you just use:
> d=: dict keys;vals
> for creating the dictionary, which is a OOP object, having the following
> methods:
> get, set, map, sort, destroy, whose documentation is contained in
> help_pdict_
>
> For performance, the create verb precomputes the lookup for the get verb,
> both forward get (key->value) and backward get inv (value->first key) upon
> object creation.
>
> *** END QUOTE
>
> I have not looked into this package, but it seems to me to have the
> right entry points.  Can we take that as a starting point to see what
> needs to be added?  The first step of course would be to put the addon
> under Package Manager.
>
> Henry Rich
>
>
>
> On 1/31/2022 12:58 PM, Elijah Stone wrote:
> > I agree with Eric regarding the challenges of adding dictionaries.
> >
> > One issue: I think a necessary prerequisite is improved symbols.
> >
> > On Mon, 31 Jan 2022, Alex Shroyer wrote:
> >
> >> I agree with Raoul that competing with Python is not a good idea.
> >> But J can learn from Python's decisions (good and bad) to grow and
> >> improve.
> >> In my opinion, numpy is Python's "killer app" because it brings
> >> reasonable
> >> 

Re: [Jprogramming] Sort

2022-03-13 Thread 'Pascal Jasmin' via Programming
Yes.  Sort sorts items which are rows in this case.

if you didn't transpose, the rows would already be sorted.




On Sunday, March 13, 2022, 08:51:22 p.m. EDT, 'Skip Cave' via Programming 
 wrote: 





Is this how sort is supposed to work?

sep=:10#.^:_1]


|:sep 120 to 130

1 1 1 1 1 1 1 1 1 1 1

2 2 2 2 2 2 2 2 2 2 3

0 1 2 3 4 5 6 7 8 9 0


/:~|:sep 120 to 130

0 1 2 3 4 5 6 7 8 9 0

1 1 1 1 1 1 1 1 1 1 1

2 2 2 2 2 2 2 2 2 2 3

Skip Cave
Cave Consulting LLC
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] prime testing on large numbers

2022-03-09 Thread 'Pascal Jasmin' via Programming
I've provided OPENSSL bindings including miller-rabin on large numbers.

https://github.com/Pascal-J/BN-openssl-bindings-for-J

openssl is/was included in windows J distributions. And available as near 
default on linux/mac afaik.

The case for libgmp may be better for "overall math" but since both are open 
source, if it were better at primality testing, openssl will copy it.  Libgmp 
may also form the heart of the CPU backend to arrayfire.  And a gpu backend 
(even universal opencl) to primality testing is the more likely successor to 
supplanting a openssl limited performance metric based replacement.






On Wednesday, March 9, 2022, 02:21:56 p.m. EST, Raul Miller 
 wrote: 





On Tue, Jan 25, 2022 at 8:38 PM Julian Fondren  wrote:
> I'll get it done.

How is this proceeding?

(I have been tempted to tackle this integration myself, but between
laptop failures and some other issues, I have not gotten around to it,
yet.)

I will say this:

Because of how J is typically installed, I think that the right
approach here would be to statically link against libgmp. Dynamic
links are appropriate in a variety of cases, but not this one, not for
the initial port. (Once libgmp is supported, it would be possible to
build J against a dynamically linked libgmp, but while that might be
right for some people, most people are not going to want to deal with
the consequences of that approach.)

Anyways, ... I might yet get around to tackling this by myself, but if
you're making good progress, I should probably either just wait or try
to pitch in on issues which are eating too much of your time.


Thanks,

-- 
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


Re: [Jprogramming] Amend an array with an array

2022-03-08 Thread 'Pascal Jasmin' via Programming
3 5 7 9 (0 0;0 1;1 0;1 1)} i.5 5






On Wednesday, March 9, 2022, 12:47:32 a.m. EST, Richard Donovan 
 wrote: 





Can I amend an array with a smaller array? For example amend a 5x5 array by a 
2x2 array starting at location x,y within the larger array?

Thanks

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


Re: [Jprogramming] Power Conjunction

2022-03-05 Thread 'Pascal Jasmin' via Programming
(+/ , 2 + {:)^:(i.8) 5 4

where your series is in first column.






On Saturday, March 5, 2022, 08:55:37 p.m. EST, 'Skip Cave' via Programming 
 wrote: 





I have this series:

5 9 15 23 33 

5+4

9

9+6

15

15+8

23

23+10

33


How can I use the power conjunction to generate this series?

Is there a more concise method to generate this than the power conjunction?


Skip


Skip Cave
Cave Consulting LLC
--
For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Higher-order arrays?

2022-03-03 Thread 'Pascal Jasmin' via Programming
> > data/metadata being a rank1/list array whose length is +/@:(*/&>)
> > boxed/meta shape

> How would this be better than a rank 1 list of boxed arrays?

Avoiding fills avoids having to interpret all fills.

The advantage of your 1 fill is that it permits item count calculation through 
*/
The disadvantage is that a shape 4 1 might be a frequently enough used shape, 
when you want to append to it.  (inverted tables for an integer field would use 
an (item,1) shape.

The advantage of 0 fill is that an (x,0) shape is not super useful (except i.0 
0 can be used to append in table form)

A _ fill is another option if 0 could create a limitation.


But then boxed format keeps your advantage of */ count, without the downside of 
cleaning/interpreting fills vs intentional values step(s).

On Thursday, March 3, 2022, 03:48:54 p.m. EST, Raul Miller 
 wrote: 





On Thu, Mar 3, 2022 at 3:28 PM 'Pascal Jasmin' via Programming
 wrote:
> I understand your metashape and data concept to be (using my prior
> example):
>
> (3 2 2 ,: 4 1 1) $ i.16
>
> would let code know that there are 12 items in 1st array, and 4 in 2nd.

That example matches how I am currently thinking about this, yes.

> And then I understand your metarank concept would be the way to tell
> if that 2nd array's shape is 4 vs 4 1 1.  A list equal to items in
> "metashape" might be what you meant?

My thinking is that the metashape would be a matrix, which would mean
that each row would have to contain the same number of elements.

However, it would be a sparse matrix (meaning that the 1s in the shape
would be represented implicitly and would appear as fill, in
operations on the metashape).

> It would seem like boxed shapes would provide the same information with

I am sure that a boxed representation could represent the same
information, but boxes are irregular -- so it does not make sense to
me to introduce a higher degree of regularity using boxes as the core
data model.

> data/metadata being a rank1/list array whose length is +/@:(*/&>)
> boxed/meta shape

How would this be better than a rank 1 list of boxed arrays?


Thanks,

--
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


Re: [Jprogramming] Higher-order arrays?

2022-03-03 Thread 'Pascal Jasmin' via Programming
for 35 atoms, I'd describe your shapes as 2 tables shape represented as (3 2 ,: 
3 9) or now ( 3 2 ; 3 9).

I understand your metarank concept to be designed for storage description, but 
it doesn't seem to be needed to describe the "shape of the shapes" if that can 
be "self calculated".

metashape 2 2 2,:9 9 9 I would understand as 8+729 items.





On Thursday, March 3, 2022, 03:21:31 p.m. EST, Raul Miller 
 wrote: 





I don't know how your model would work, but in the model I was
thinking of, a meta array with metarank 2 3 and metashape 2 2 2,:9 9 9
would contain 35 integers.

How many integers would the meta array contain in your model?

Thanks,

-- 
Raul

On Thu, Mar 3, 2022 at 3:06 PM 'Pascal Jasmin' via Programming
 wrote:
>
> when "subarrays" are all the same rank and there are x such items then shape 
> is x , subarrayShape.
>
> exotic/table shapes would seem to fit with the arrays of arrays exotic 
> concept.
>
>
>
>
>
>
> On Thursday, March 3, 2022, 02:52:14 p.m. EST, Raul Miller 
>  wrote:
>
>
>
>
>
> Conceptually, I think an "array" whose "shape's rank" is higher than 1
> should represent a collection of arrays of the same rank.
>
> --
> Raul
>
> On Thu, Mar 3, 2022 at 11:50 AM 'Pascal Jasmin' via Programming
>  wrote:
> >
> > I'm ok with the 0s, but another way to have 2 shapes (referring to 2 
> > arrays) of different sizes ie. one of 3 2 2 the other shape 4, would be 
> > that the "shape of the shapes" is a "by 1 table":
> >
> > 3
> > 1
> >
> > so
> >
> > (3 ,:1) $ 3 2 2 4 would be the shape of i.  (3 ,:1) $ 3 2 2 4  or ((3 ,:1) 
> > $ 3 2 2 4) $ i.16
> >
> > I'm ok with this as a formal definition for arrays of arrays, but I would 
> > definitely create a verb named shape to ease with typing and even 
> > processing/reshaping such that
> >
> > ((3 ,:1) $ 3 2 2 4) $ i.16
> >
> > would be equivalent to
> >
> > (3 2 2 ,: 4) shape i.16
> >
> > ie. in table shapes, trailing 0s (fills) are equivalent to axes not being 
> > present.  I don't think this loses very much in expressibility, though I 
> > understand that it creates an extra computation step to properly understand 
> > a "shape item" with trailing 0s.
> >
> >
> > On Thursday, March 3, 2022, 11:01:57 a.m. EST, Henry Rich 
> >  wrote:
> >
> >
> >
> >
> >
> > I like this, except for the trailing-0 bit. I would say having data with
> > trailing 0 shape is 'common' rather than 'ultra-rare'.
> >
> > Henry Rich
> >
> > On 3/3/2022 10:15 AM, 'Pascal Jasmin' via Programming wrote:
> > > I don't have a good grasp of order, but a different practical 
> > > interpretation of non-list shapes:
> > >
> > > 1. You mentioned distinguishing atoms from lists of 1 element.  J already 
> > > manages this well, and making an atomic shape result would not be of any 
> > > help, IMO.
> > >
> > > 2. A table shape could be a code for ragged arrays, or arrays of arrays.  
> > > The following shape:
> > >
> > > 3 2 2
> > > 4 0 0
> > >
> > > Would be 2 arrays, the first is shape 3 2 2, and the 2nd is shape 4.  
> > > Trailing 0s would be fills. This precludes the ultra rare need of needing 
> > > an "embedded" shape 4 0 or shape 4 0 0 in your data.
> > >
> > > A list of 3 strings/lists with individual lengths of 2 3 4 would have the 
> > > shape:
> > >
> > > 2
> > > 3
> > > 4
> > >
> > > If there is an extention of the meaning of shape, I'd prefer it be in 
> > > this direction rather than ultra high dimensional math that hurts my head.
> > >
> > >
> > > On Thursday, March 3, 2022, 05:13:27 a.m. EST, Elijah Stone 
> > >  wrote:
> > >
> > >
> > >
> > >
> > >
> > > A little thought exercise I embarked upon.
> > > Probably not very clearly expressed, and certainly of no practical use,
> > > but I think there are some interesting ideas:
> > >
> > > Why must the result of $y always be a vector?  What would happen if we let
> > > it be a higher-ranked array?  What would that _mean_?
> > >
> > > Well, say that 2 3 4-:$y.  That means that y is a mapping from arrays x
> > > that have the same shape as 2 3 4 (and whose elements are natural and
> > > bounded by 2 3 4).  In other words, if (x -:&$ 2 3 4) *. -. 0 e. x<2 3 4
> > > then ( &

Re: [Jprogramming] Higher-order arrays?

2022-03-03 Thread 'Pascal Jasmin' via Programming
I understand your metashape and data concept to be (using my prior example):

(3 2 2 ,: 4 1 1) $ i.16

would let code know that there are 12 items in 1st array, and 4 in 2nd.

And then I understand your metarank concept would be the way to tell if that 
2nd array's shape is 4 vs 4 1 1.  A list equal to items in "metashape" might be 
what you meant?

It would seem like boxed shapes would provide the same information with

data/metadata being a rank1/list array whose length is +/@:(*/&>) boxed/meta 
shape




On Thursday, March 3, 2022, 03:05:05 p.m. EST, Raul Miller 
 wrote: 





We could model a meta array as a boxed list with three elements:

metarank; metashape; metadata

metarank would be a two element list (a dense array).

And, metashape would be rank 2, both dimensions would be sparse, with
a fill element of 1.

And, metadata might be a dense rank 1 array whose length is +/*/"1 metashape.

Obviously, different models are possible.

But the question would be: how would J's operations (like rank) be
extended to operate on this modeled data?

What would an index into this hypothetical meta array look like?

Thanks,

-- 
Raul


On Thu, Mar 3, 2022 at 2:56 PM 'Pascal Jasmin' via Programming
 wrote:
>
> correcting a typo/bug written earlier
>
> (3 2 2 ,: 4) shape i.16
>
> should be
>
> (3 2 2 ,: ,4) shape i.16
>
> Another way to specify/return ragged shapes would be in boxed form.  I would 
> not have made the above typo if the input form for ragged shapes were boxes.  
> So
>
> (3 2 2;4) as a shape does not need to care about padding, and then some other 
> future meaning for table shapes could be looked into.
>
>
>
>
>
>
> On Thursday, March 3, 2022, 11:50:25 a.m. EST, 'Pascal Jasmin' via 
> Programming  wrote:
>
>
>
>
>
> I'm ok with the 0s, but another way to have 2 shapes (referring to 2 arrays) 
> of different sizes ie. one of 3 2 2 the other shape 4, would be that the 
> "shape of the shapes" is a "by 1 table":
>
> 3
> 1
>
> so
>
> (3 ,:1) $ 3 2 2 4 would be the shape of i.  (3 ,:1) $ 3 2 2 4  or ((3 ,:1) $ 
> 3 2 2 4) $ i.16
>
> I'm ok with this as a formal definition for arrays of arrays, but I would 
> definitely create a verb named shape to ease with typing and even 
> processing/reshaping such that
>
> ((3 ,:1) $ 3 2 2 4) $ i.16
>
> would be equivalent to
>
> (3 2 2 ,: 4) shape i.16
>
> ie. in table shapes, trailing 0s (fills) are equivalent to axes not being 
> present.  I don't think this loses very much in expressibility, though I 
> understand that it creates an extra computation step to properly understand a 
> "shape item" with trailing 0s.
>
>
> On Thursday, March 3, 2022, 11:01:57 a.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> I like this, except for the trailing-0 bit. I would say having data with
> trailing 0 shape is 'common' rather than 'ultra-rare'.
>
> Henry Rich
>
> On 3/3/2022 10:15 AM, 'Pascal Jasmin' via Programming wrote:
> > I don't have a good grasp of order, but a different practical 
> > interpretation of non-list shapes:
> >
> > 1. You mentioned distinguishing atoms from lists of 1 element.  J already 
> > manages this well, and making an atomic shape result would not be of any 
> > help, IMO.
> >
> > 2. A table shape could be a code for ragged arrays, or arrays of arrays.  
> > The following shape:
> >
> > 3 2 2
> > 4 0 0
> >
> > Would be 2 arrays, the first is shape 3 2 2, and the 2nd is shape 4.  
> > Trailing 0s would be fills. This precludes the ultra rare need of needing 
> > an "embedded" shape 4 0 or shape 4 0 0 in your data.
> >
> > A list of 3 strings/lists with individual lengths of 2 3 4 would have the 
> > shape:
> >
> > 2
> > 3
> > 4
> >
> > If there is an extention of the meaning of shape, I'd prefer it be in this 
> > direction rather than ultra high dimensional math that hurts my head.
> >
> >
> > On Thursday, March 3, 2022, 05:13:27 a.m. EST, Elijah Stone 
> >  wrote:
> >
> >
> >
> >
> >
> > A little thought exercise I embarked upon.
> > Probably not very clearly expressed, and certainly of no practical use,
> > but I think there are some interesting ideas:
> >
> > Why must the result of $y always be a vector?  What would happen if we let
> > it be a higher-ranked array?  What would that _mean_?
> >
> > Well, say that 2 3 4-:$y.  That means that y is a mapping from arrays x
> > that have the same shape as 2 3 4 (and whose elements are natural and
> > bounded by 2 3 4).  In other words, if (x -:&$ 2 3 4) *. -. 0 e. x<2

Re: [Jprogramming] Higher-order arrays?

2022-03-03 Thread 'Pascal Jasmin' via Programming
when "subarrays" are all the same rank and there are x such items then shape is 
x , subarrayShape.

exotic/table shapes would seem to fit with the arrays of arrays exotic concept.






On Thursday, March 3, 2022, 02:52:14 p.m. EST, Raul Miller 
 wrote: 





Conceptually, I think an "array" whose "shape's rank" is higher than 1
should represent a collection of arrays of the same rank.

-- 
Raul

On Thu, Mar 3, 2022 at 11:50 AM 'Pascal Jasmin' via Programming
 wrote:
>
> I'm ok with the 0s, but another way to have 2 shapes (referring to 2 arrays) 
> of different sizes ie. one of 3 2 2 the other shape 4, would be that the 
> "shape of the shapes" is a "by 1 table":
>
> 3
> 1
>
> so
>
> (3 ,:1) $ 3 2 2 4 would be the shape of i.  (3 ,:1) $ 3 2 2 4  or ((3 ,:1) $ 
> 3 2 2 4) $ i.16
>
> I'm ok with this as a formal definition for arrays of arrays, but I would 
> definitely create a verb named shape to ease with typing and even 
> processing/reshaping such that
>
> ((3 ,:1) $ 3 2 2 4) $ i.16
>
> would be equivalent to
>
> (3 2 2 ,: 4) shape i.16
>
> ie. in table shapes, trailing 0s (fills) are equivalent to axes not being 
> present.  I don't think this loses very much in expressibility, though I 
> understand that it creates an extra computation step to properly understand a 
> "shape item" with trailing 0s.
>
>
> On Thursday, March 3, 2022, 11:01:57 a.m. EST, Henry Rich 
>  wrote:
>
>
>
>
>
> I like this, except for the trailing-0 bit. I would say having data with
> trailing 0 shape is 'common' rather than 'ultra-rare'.
>
> Henry Rich
>
> On 3/3/2022 10:15 AM, 'Pascal Jasmin' via Programming wrote:
> > I don't have a good grasp of order, but a different practical 
> > interpretation of non-list shapes:
> >
> > 1. You mentioned distinguishing atoms from lists of 1 element.  J already 
> > manages this well, and making an atomic shape result would not be of any 
> > help, IMO.
> >
> > 2. A table shape could be a code for ragged arrays, or arrays of arrays.  
> > The following shape:
> >
> > 3 2 2
> > 4 0 0
> >
> > Would be 2 arrays, the first is shape 3 2 2, and the 2nd is shape 4.  
> > Trailing 0s would be fills. This precludes the ultra rare need of needing 
> > an "embedded" shape 4 0 or shape 4 0 0 in your data.
> >
> > A list of 3 strings/lists with individual lengths of 2 3 4 would have the 
> > shape:
> >
> > 2
> > 3
> > 4
> >
> > If there is an extention of the meaning of shape, I'd prefer it be in this 
> > direction rather than ultra high dimensional math that hurts my head.
> >
> >
> > On Thursday, March 3, 2022, 05:13:27 a.m. EST, Elijah Stone 
> >  wrote:
> >
> >
> >
> >
> >
> > A little thought exercise I embarked upon.
> > Probably not very clearly expressed, and certainly of no practical use,
> > but I think there are some interesting ideas:
> >
> > Why must the result of $y always be a vector?  What would happen if we let
> > it be a higher-ranked array?  What would that _mean_?
> >
> > Well, say that 2 3 4-:$y.  That means that y is a mapping from arrays x
> > that have the same shape as 2 3 4 (and whose elements are natural and
> > bounded by 2 3 4).  In other words, if (x -:&$ 2 3 4) *. -. 0 e. x<2 3 4
> > then ( > possibility of sentences such as ((<1 1){y)  ((<,1){y)  ((<1){y)  and so
> > on; consider these sentences ill-formed for the time being.)
> > Generalising: if (x -:&$ $y) *. -. 0 e. x<$y then ( > as an atom.
> >
> > But this sentence makes no restrictions whatsoever on the rank of x!  So
> > it would seem that we've discovered a way to make a y whose shape is an
> > array of any rank.  But we must be careful.  Really, all we've constructed
> > is a strange entity y--call it an array-as-we-do-not-know-it--and, on
> > arrays-as-we-do-not-know-them, we have defined that: $y is well-defined,
> > and evaluates to an array-as-we-know-it.  x{y is well-defined for some
> > subset of arrays-as-we-know-them x, and evaluates to an
> > atom-as-we-know-it.
> >
> > I will call this strange creature a 4th-order array.  And all
> > arrays-as-we-know-them are 3rd-order (this includes scalars, vectors, and
> > higher-rank arrays).  A 4th-order array has a shape which is a 3rd-order
> > array, and maps from 3rd-order arrays to atoms.  This suggests the
> > existence of lower-order arrays, and higher-order ones.
> >
> > Following the same logic, then, a 3rd-order array would map 2nd-order
&

  1   2   3   4   5   6   7   8   9   10   >