I fixed the link to be to the j only j by example page.  Messed up original 
somehow.

In terms of what I liked about the python page was that its start focus was on 
task patterns (printing things), and sample complete programs.

Still, your suggestion would be an excellent both impressive and approachable 
tutorial.


----- Original Message -----
From: Henry Rich <[email protected]>
To: [email protected]
Cc: 
Sent: Sunday, September 7, 2014 11:07 AM
Subject: Re: [Jprogramming] J Kernel

J By Example is interesting, but I think you should remove the K, which 
will only be confusing.  But it's not for the novice anyway.

I like the idea of simple programs.  The Python page didn't do much for 
me; the programs were either too easy or too hard.  Perhaps we can do 
better.

The hard part is coming up with the problems to solve.  Here's Project 
Euler problem 1:

NB. Find the sum of all the multiples of 3 or 5 below 1000.
NB. Solutions will be by creating a sieve of the numbers, then summing.

NB. Solution 0, typed at the console:
    mask3 =. 1000 $ 3 {. 1  NB. Create the pattern 1 0 0 and repeat it
    mask3  NB. Display it
1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0...
    mask5 =. 1000 $ 5 {. 1  NB. Create the pattern 1 0 0 0 0 and repeat
    mask5
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0...
    mask35 =. mask3 +. mask5  NB. Boolean OR
    mask35
1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 0...
    I. mask35   NB. The numbers that correspond to the 1s
0 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48...
    +/ I. mask35  NB. Their total
233168

NB. The same, typed into the console as 1 line
    +/ I. (1000 $ 3 {. 1) +. (1000 $ 5 {. 1)
233168

NB. Solution 2.  The same, collected into a verb (i. e. a program)
    PE1 =: verb define
+/ I. (1000 $ 3 {. 1) +. (1000 $ 5 {. 1)
)
    PE1 ''  NB. Execute the program
233168

NB. Solution 3.  Generalized to find all numbers less than the
NB. right argument (denoted y) that are multiples of any
NB. number in the left argument (denoted x)
    PE1 =: dyad define
masks =. (y $ {.&1)"0 x   NB. One mask for each number in x
combinedmasks =. +./ masks  NB. Boolean OR of all of these
+/ I. combinedmasks  NB. The total
)
    3 5 PE1 1000
233168
    3 5 7 PE1 2000
1083288

NB. Solution 4.  The same, represented in tacit form
NB. Wouldn't it be cool to learn how to do this?
    PE1 =: +/ @: I. @ (+./) @: (($ {.&1)"0) ~  NB. The entire program!

    3 5 PE1 1000
233168
    3 5 7 PE1 2000
1083288


Henry Rich

On 9/7/2014 9:38 AM, 'Pascal Jasmin' via Programming wrote:
> I like the python page, but I also like the J by example link I added to 
> http://www.jsoftware.com/jwiki/Vocabulary/HowNuVoc a couple of weeks ago.
>
>
>
> ----- Original Message -----
> From: Ian Clark <[email protected]>
> To: [email protected]
> Cc:
> Sent: Sunday, September 7, 2014 5:35 AM
> Subject: Re: [Jprogramming] J Kernel
>
> Minimal Beginning J fills an important gap. One I had on my list to fill
> urgently -- but Devon's got there first, with a surprisingly simple starter
> set. Good Work, Devon!
>
> Initially I was tempted to second-guess Devon by tweaking his list. Soon I
> was convinced that if somebody could improve upon it, that somebody wasn't
> me.
>
> People coming from C, Basic, Python, etc etc will straightaway say: hey
> where's a[3] ? Should we give them {  and } ? By the same token, people
> coming from Fortran (and Basic) will say: hey where's GOTO? Should we give
> them (goto_name.)?
>
> Bear in mind that Minimal Beginning J is the first rung on a long ladder.
> The hitherto missing first rung! Since it already offers }. {. and # -- why
> not leave { and } to the second rung?
>
> What's still badly needed though is some evidence this starter set is good
> enough for some recognizable programming of a general nature. Not just fit
> for knocking down a few carefully chosen straw-men.
>
> I know little or no Python, so a visit to www.python.org is most
> instructive -- and very sobering. Almost the first thing a beginner like me
> sees is a list of "Simple programs" (
> https://wiki.python.org/moin/SimplePrograms).
>
> We could do worse than rip-off this list of coding tasks *exactly* as it
> stands and show them in Minimal Beginning J. A sort of "Minimal Beginning
> Rosetta", if-you-will. I know "me-too" isn't that sexy a sport -- but is
> the first rung really the place for "me-only"?
>
>
> On Thu, Sep 4, 2014 at 4:12 AM, Scott Locklin <[email protected]> wrote:
>
>> Nice work, Devon.
>> One of the things I would like to do eventually is a sort of "J for
>> Matlab/R programmers." I figure J is vastly more useful as a general
>> purpose language than these, but it is also first rate for all kinds of
>> numerics and mathematical applications. There is a large population of math
>> people who would prefer something better than Matlab or R, but for most
>> languages, math is sort of a second class citizen.
>>
>> -SL
>>
>> ----------------------------------------------------------------------
>> 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

Reply via email to