Re: [Jprogramming] sequential machine

2018-02-19 Thread Arnab Chakraborty
Wow, thank you so much, friends, for so much help. With my present level of profficiency in J, I'll need some time before I can make complete sense of the J codes. Shall report back after that. On 19 Feb 2018 01:10, "Cliff Reiter" wrote: > A cut variant of "words" >(<;.1~1,2 ~:/\ ])I > > +-

[Jprogramming] Sliding window

2018-02-19 Thread Skip Cave
How can one create a sliding window in J? 3 sw i.6 0 1 2 1 2 3 2 3 4 3 4 5 4 sw i.7 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 What is the J code for sw? Skip Cave Cave Consulting LLC -- For information about J forums see htt

Re: [Jprogramming] Sliding window

2018-02-19 Thread Raul Miller
3 ]\i.6 0 1 2 1 2 3 2 3 4 3 4 5 Or sw=: ]\ Thanks, -- Raul On Mon, Feb 19, 2018 at 2:09 PM, Skip Cave wrote: > How can one create a sliding window in J? > > 3 sw i.6 > > 0 1 2 > 1 2 3 > 2 3 4 > 3 4 5 > > 4 sw i.7 > 0 1 2 3 > 1 2 3 4 > 2 3 4 5 > 3 4 5 6 > 4 5 6 7 > > What is the J code

Re: [Jprogramming] Sliding window

2018-02-19 Thread Henry Rich
Look into the likes of    +/~ i. 4 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 Change as needed to meet your spec. Henry Rich On 2/19/2018 2:09 PM, Skip Cave wrote: How can one create a sliding window in J? 3 sw i.6 0 1 2 1 2 3 2 3 4 3 4 5 4 sw i.7 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 What

Re: [Jprogramming] Sliding window

2018-02-19 Thread Michael Dykman
Will this do? sw =: 1 : 'm ]\]' 3 sw i.6 0 1 2 1 2 3 2 3 4 3 4 5 4 sw i.7 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 On 19 February 2018 at 14:09, Skip Cave wrote: > How can one create a sliding window in J? > > 3 sw i.6 > > 0 1 2 > 1 2 3 > 2 3 4 > 3 4 5 > > 4 sw i.7 > 0 1 2 3 > 1 2 3 4 > 2

Re: [Jprogramming] Sliding window

2018-02-19 Thread robert therriault
Probably just a glitch in what you are looking for in the second example, but it can be done with a little processing before using ]\ 4 ]\ i. 7 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 4 (]\ (, >:@{:)) i.7 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 Cheers, bob > On Feb 19, 2018, at 11:13 AM, Raul Mi

[Jprogramming] addons/api/python3 updated

2018-02-19 Thread Eric Iverson
The python3 addon has been updated with bug fixes. Please share your experiences with this new facility. -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Sliding window

2018-02-19 Thread Skip Cave
Thanks to all the informative responses. I knew there had to be a way to use \ for the sliding window, but it didn't occur to me to use ] to access the right argument. so ]\1 2 3 1 0 0 1 2 0 1 2 3 but 1 2 3\1 2 3 |domain error | 1 2 3 \1 2 3 I thought that ] replicated the right argument

Re: [Jprogramming] Sliding window

2018-02-19 Thread Raul Miller
Or: 4 ]\ i.8 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 It was a hand-constructed example - it's easy to say something slightly different from what you want when you're doing that. Thanks, -- Raul On Mon, Feb 19, 2018 at 2:21 PM, robert therriault wrote: > Probably just a glitch in what you

Re: [Jprogramming] Sliding window

2018-02-19 Thread Skip Cave
​​ Yes , my second example was hand- constructed, and I should have left off the last line - 4 5 6 7 4 ]\ i.7 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 Skip Cave Cave Consulting LLC On Mon, Feb 19, 2018 at 1:38 PM, Raul Miller wrote: > Or: > >4 ]\ i.8 > 0 1 2 3 > 1 2 3 4 > 2 3 4 5 > 3 4 5 6

Re: [Jprogramming] Sliding window

2018-02-19 Thread Jimmy Gauvin
​​ 0 1 2 3 4]\1 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 3 0 0 0 0 0 0 0 1 2 0 0 2 3 0 0 0 0 0 0 0 0 0 0 1 2 3 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 1 2 3 4<\1 2 3 ┌─┬───┬─┬┐ │ │ │ ││ ├─┼───┼─┼┤ │1│2 │3││ ├─┼───┼─┼┤ │1 2 │2 3│ ││ ├─

Re: [Jprogramming] Sliding window

2018-02-19 Thread Raul Miller
[I'm using parenthesis, here to separate j expressions from surrounding english text. That might be a little unfamiliar, but hopefully it's not too bad... And, on the plus side, parenthesis are valid J when their contents are valid J.] ] does replicate the right argument. And, for monadic verbs -

Re: [Jprogramming] Sliding window

2018-02-19 Thread robert therriault
Raul, I think I would have stopped with this part of your explanation. > On Feb 19, 2018, at 11:47 AM, Raul Miller wrote: > > But keep in mind that the verb (]\) has two definitions: a monadic > definition and a dyadic definition. So you should expect a different > result from (3 ]\ i.4) than

Re: [Jprogramming] Sliding window

2018-02-19 Thread Raul Miller
This is getting away from programming, tempting to take it to chat.. But if we're going to talk about technical details, the words we use will tend to become technical. That said... "dyadic adverb" sounds like a shortcut - and an ambiguous one at that. So let's take it back a step: You combine a

Re: [Jprogramming] Sliding window

2018-02-19 Thread Skip Cave
Raul said: However, (1 2 3) is not a verb. So that gives you a domain error right there, regardless of any right argument: Doh! NOW i get it. ] is the verb and 3 is the noun. So any verb should work... 3<\1 2 3 4 5 ┌─┬─┬─┐ │ 1 2 3 │ 2 3 4 │ 3 4 5 │ └─┴─┴─┘ 3{.\1 2 3

Re: [Jprogramming] Sliding window

2018-02-19 Thread Raul Miller
Actually, 3 {.\ 1 2 3 4 5 worked: {. 1 2 3 gives you 1 {. 2 3 4 gives you 2 {. 3 4 5 gives you 3 So... the result of using {. with a sliding window is the first element from each of those window instances. Thanks, -- Raul On Mon, Feb 19, 2018 at 3:24 PM, Skip Cave wrote: > Raul said: > > H

Re: [Jprogramming] Sliding window

2018-02-19 Thread robert therriault
Raul, Yes you are right. The term "dyadic adverb" is a symptom of a fuzzy thinking shortcut on my part. The rest of your explanation clarifies the issue. Cheers, bob > On Feb 19, 2018, at 12:21 PM, Raul Miller wrote: > > That said... "dyadic adverb" sounds like a shortcut ---

Re: [Jprogramming] addons/api/python3 updated

2018-02-19 Thread Gilles Kirouac
I had j806/j64/windows, I installed Python 3.6.4 today for my single use (rather than all users). I then had difficulty with "import j". "put j.py and j_config.py where python can find them" I initially placed them with other scripts under Tools\scripts, but that did not work. Putting them in the

Re: [Jprogramming] addons/api/python3 updated

2018-02-19 Thread Raul Miller
To find where your python installation looks for python files, start python and do this: import sys print sys.path Thanks, -- Raul On Mon, Feb 19, 2018 at 8:17 PM, Gilles Kirouac wrote: > I had j806/j64/windows, I installed Python 3.6.4 today for my single use > (rather than all users). > >

Re: [Jprogramming] addons/api/python3 updated

2018-02-19 Thread Eric Iverson
Thanks for the python feedback. I am completely new to python so when I said 'put [them] where python can find them' I was depending on knowledge beyond my own. I developed them in my home folder, but assume there are other, probably better, places. The '\u...' hint is amusing, but not sure how t

Re: [Jprogramming] addons/api/python3 updated

2018-02-19 Thread bill lam
You can use environment variable PYTHONPATH to prepend search paths to the default, eg I add in .profile export PYTHONPATH=$HOME/python_module in python session, >>> sys.path ['', '/home/bill/python_module', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/loc

Re: [Jprogramming] sequential machine

2018-02-19 Thread Arnab Chakraborty
Hello Raul, I have been able to understand the code you sent me. Thanks. Your code helped me to learn some other nuances of J as well! I had come to a somewhat different solution before I saw you reply. Here it is for comparison. Actually I did not use ;: at all. Instead, I chose a mor

Re: [Jprogramming] sequential machine

2018-02-19 Thread Raul Miller
Hmm... I think you should view the state machine as a component in a larger system. I say this because other languages tend to encourage you to push functionality into loops [loops are a bit laborious and noisy to write, so you tend to want to not write many of them], but that's not always a good

Re: [Jprogramming] sequential machine

2018-02-19 Thread Henry Rich
The idiomatic way to pass state from execution on one cell to the execution on the next is with u/ or u/\., depending on whether you need the result from each cell or just the final result.  You write |. u/\. (|. array) , initialvalue and u is repeatedly executed between (cell of y) and (previ