Re: [Jprogramming] 'Tis the Season...

2015-12-01 Thread Ric Sherlock
mine was similar to Joe's floor=: [: +/@:<: ') ('&i. On Wed, Dec 2, 2015 at 11:17 AM, Joe Bogner wrote: > +/ (1,_1) {~ '()' i. S > > or > > +/ _1 + ') (' i. S > > On Tue, Dec 1, 2015 at 5:09 PM, 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > -/ #/.~ S > > > > > > >

Re: [Jprogramming] 'Tis the Season...

2015-12-01 Thread Ric Sherlock
Nice idea but is dependent on the order of then input. -/ #/.~ ')', S _73 This would sort that: -/ <: #/.~ '()' , S On Wed, Dec 2, 2015 at 11:09 AM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > -/ #/.~ S > > > > > - Original Message - > From: Geoff Canyon

Re: [Jprogramming] 'Tis the Season...

2015-12-01 Thread Ric Sherlock
Then you can't go to the basement? On Wed, Dec 2, 2015 at 11:41 AM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > or > > | -/ #/.~ S > > > > > - Original Message - > From: Ric Sherlock > To: Programming JForum

Re: [Jprogramming] advent of code - day 2

2015-12-02 Thread Ric Sherlock
Here's mine: require 'tables/csv stats' parcels=: _99 ". > 'x' readdsv jpath '~temp/aoc_day2_inp.txt' NB. Part 1 +/ (<./ + [: +/ +:)"1 */"1 (0 1 , 1 2 ,: 0 2) {"_ 1 parcels NB. or... getFaceSides=: (2 comb 3) {"_ 1 ] calcFaceArea=: */"1@:getFaceSides calcPaper=: (<./ + +/@:+:)"1 calcTotalPap

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread Ric Sherlock
I struggled with an efficient tacit implementation too and went with a for loop to sequentially update the array. I love Henry's take on the problem! parseInstructs=: 3 :0 tmp=. y rplc 'turn ';'';'through ';'' action=. <@(' '&taketo);._2 tmp coords=. ". ' '&takeafter;._2 tmp action=. (

Re: [Jprogramming] advent 7

2015-12-13 Thread Ric Sherlock
I used an algorithm used to sort pedigrees to get the instructions in order and then used the method Henry introduced earlier to get the value of a. Part 2 took me a bit longer because I misunderstood the question and thought that I had to iterate until the value of a stabilized (not just run it on

Re: [Jprogramming] Genetic algorithms?

2015-12-17 Thread Ric Sherlock
I have done some work using Differential Evolution (see the math/deoptim addon). Another simple example would be the rosettacode task: http://rosettacode.org/wiki/Evolutionary_algorithm#J On Fri, Dec 18, 2015 at 9:52 AM, Devon McCormick wrote: > Has anyone done work in J on genetic algorithms?

Re: [Jprogramming] cool ipython notebook integration of J

2016-01-06 Thread Ric Sherlock
I did a course recently that used Jupyter notebooks as the interface for Julia and wondered at the time how hard it would be to get a J kernel running for it. We were each using Jupyter locally as our interface to the language. We were provided with notebooks that described problems and were able

Re: [Jprogramming] Qt form with plot

2016-01-06 Thread Ric Sherlock
See also the demo in the math/deoptim addon load 'math/deoptim/demo/eg_deoptim' click the "Start" button to plot the progress towards solving the problem. On Thu, Jan 7, 2016 at 2:48 PM, Norman Drinkwater wrote: > Yes, the form has both a toolbar and menus. > > > On Jan 6, 2016, at 7:44 PM, Jo

Re: [Jprogramming] Morning Mystery

2016-02-25 Thread Ric Sherlock
Nice! Continuing with the assumption that not all digits need to be used, the sentence can be further shortened to 17 chars %/({:,+/)^:(3*5)1 0.618034 On Thu, Feb 25, 2016 at 10:25 PM, Ben Gorte - CITG wrote: > I noticed a golden ratio. > >%/({:,+/)^:(3*4*5)[1 2 NB. 6, 7, 8 and 9 n

Re: [Jprogramming] Fractals, Visualization and J, Fourth edition, Part 1

2016-03-01 Thread Ric Sherlock
I haven't played with this stuff before and found the result quite magical. Here is what I ended up with... require 'plot' fm=: {&(_2 (]\"1) 4 {."1 f) fa=: {&(4 5 {"1 f) prob=: (+/\ 6 {"1 f) I. ?@0: ifs=: prob (fa@[ + fm@[ +/ .* ]) ] getPoints=: ifs^:(<20) plotFern=: 'dot' plot ;/@|:

Re: [Jprogramming] Fractals, Visualization and J, Fourth edition, Part 1

2016-03-01 Thread Ric Sherlock
0.44 0.07 ) plotFern getPoints 0 0 On Wed, Mar 2, 2016 at 11:02 AM, Ric Sherlock wrote: > I haven't played with this stuff before and found the result quite magical. > Here is what I ended up with... > > require 'plot' > > > fm=: {&am

Re: [Jprogramming] Fractals, Visualization and J, Fourth edition, Part 1

2016-03-01 Thread Ric Sherlock
Yes you're right thanks. I'd originally been thinking of giving f as an argument so that it would be possible to easily do mutated ferns as per the wikipedia page, but didn't get there in the end and didn't check in a clean session. I've added it to the RosettaCode page for now until a better versi

Re: [Jprogramming] Reading text .csv files into a J array

2016-03-03 Thread Ric Sherlock
Many of the addons have documentation on the wiki: Note that the 'tables/csv' addon http://code.jsoftware.com/wiki/Addons/tables/csv is a special case of the 'tables/dsv' addon which lets you specify custom delimiters. http://code.jsoftware.com/wiki/Addons/tables/dsv On Fri, Mar 4, 2016 at 12:16

Re: [Jprogramming] Reading text .csv files into a J array

2016-03-03 Thread Ric Sherlock
Note also: assign2hdr readcsv 'c:\tst1.csv' col1 +---+---++ |abc|def|ghij| +---+---++ col2 ++++ |c101|c102|c201| ++++ col3 1 1 2 On Fri, Mar 4, 2016 at 1:04 PM, Ric Sherlock wrote: > Many of the addons have documentatio

Re: [Jprogramming] Jsoftware dot com / papers

2016-03-06 Thread Ric Sherlock
The link works for me at the moment. Maybe try again and see if it still doesn't work for you? On Mon, Mar 7, 2016 at 12:45 PM, Louis de Forcrand wrote: > Not so long ago there used to be a web page www.jsoftware.com/papers, but > now I can't load it. Has it been taken down? Some of the papers o

Re: [Jprogramming] Is variable defined

2016-03-10 Thread Ric Sherlock
The foreign conjunction you're after is 4!:0 blah=: 403 4!:0 <'blah' 0 4!:0 <'notblah' _1 The verb type is defined in the stdlib that is loaded at startup so: type 'blah' ++ |noun| ++ type 'blahnot' +---+ |not defined| +---+ On Fri, Mar 11, 2016

Re: [Jprogramming] Writing a dyadic verb

2016-03-28 Thread Ric Sherlock
One option is to use a dyadic hook (rather than 5 (= +/)&:*: 3 4 If you want to use the same argument order as before: 3 4 (= +/)&:*:~ 5 Another option would be not to separate the triangle sides: isRightTri=: ({: = +/@:}:)@:*:@/:~"1 isRightTri 3 4 5 , 5 9 6 ,: 5 16 20 1 0 0 On Tue, Mar 29,

Re: [Jprogramming] Weighty stats

2016-03-29 Thread Ric Sherlock
Here's an attempt to come up with weighted versions in the spirit of the univariate.ijs definitions wmean=: +/@[ %~ +/@:* wdev=: ] -"_1 _ wmean wssdev=: [ +/@:* *:@wdev wvar=: (#@-.&0 %~ <:@#@-.&0 * +/)@[ %~ wssdev wstddev=: %:@wvar 1 1 0 0 4 1 2 1 0 wstddev 2 3 5 7 11 13 17 19 23 5.8223

Re: [Jprogramming] Problem with jqt and floating point display

2016-04-05 Thread Ric Sherlock
Do you get the same behaviour from the jconsole as you do in jqt? On Wed, Apr 6, 2016 at 9:37 AM, Andres Purwin wrote: > Hello Raul, > > Thank you for your answer. I tried it, but unfortunately the suggested > solution doesn't work. > > Andres > > Am 05.04.2016 um 21:55 schrieb Raul Miller: > >>

Re: [Jprogramming] Plot not showing

2016-04-06 Thread Ric Sherlock
I can't replicate your results above. Using your verb: plottest (i.10),:3+i.10 NB. two dashed lines plottest i.10NB. one dashed line plottest ,: i. 10NB. one dashed line On Thu, Apr 7, 2016 at 12:36 PM, Ryan Eckbo wrote: > I'm trying to plot one dashed line, but it seems

Re: [Jprogramming] divide if not zero

2016-05-05 Thread Ric Sherlock
How about: 3 2 4 (% * 0 ~: ]) 6 0 3 0.5 0 1.3 On Fri, May 6, 2016 at 12:57 PM, Rob Hodgkinson wrote: > if you want to avoid the use of power ^: then just add 1 to y where y=0… >x(%]+0=])y > 0.5 2 1.3 > > > > On 6 May 2016, at 10:53 AM, 'Pascal Jasmin' via Programming < > prog

[Jprogramming] J-like approach for merging numbers in a list

2016-06-07 Thread Ric Sherlock
I'm looking for a J-like approach to a verb for merging adjacent numbers in a row where the numbers are the same. For example mergerow 4 4 4 4 8 8 mergerow 8 8 16 mergerow 16 16 mergerow 4 4 4 8 4 mergerow 8 4 8 4 mergerow 4 8 8 4 4 16 4 My version below which I've used as part of the

Re: [Jprogramming] J-like approach for merging numbers in a list

2016-06-07 Thread Ric Sherlock
> > Thanks, > > -- > Raul > > > On Tue, Jun 7, 2016 at 5:15 PM, Ric Sherlock wrote: > > I'm looking for a J-like approach to a verb for merging adjacent numbers > in > > a row where the numbers are the same. For example > > > > mergerow 4 4

Re: [Jprogramming] J-like approach for merging numbers in a list

2016-06-07 Thread Ric Sherlock
-- > Raul > > On Tue, Jun 7, 2016 at 6:10 PM, Ric Sherlock wrote: > > Thanks that's much nicer. > > The only case it doesn't handle is the empty arg (which I didn't put in > my > > spec!). > > > >mergeRow

Re: [Jprogramming] J-like approach for merging numbers in a list

2016-06-07 Thread Ric Sherlock
hift the 2&| inside, and > > note that (2|+) is the same as (~:) on binary inputs. Then ([*~:) turns > > out to be equal to (>) on binary inputs, a fact I found just by > > computing the truth table. > > > >([*~:)/\.&.|. m > > 0 1 0 1 0 0 0 1 0 0

[Jprogramming] Capturing an arrow key press event in wd GUI?

2016-06-20 Thread Ric Sherlock
​ Is it possible to capture an Arrow keypress event in a WD-based Qt application? I have developed a J version of the 2048 game with a WD interface that I plan to release as an addon. https://github.com/tikkanz/g2048 Currently I use menu shortcuts (Ctrl+w/s/a/d) to support the keyboard, but it wo

[Jprogramming] New 2048 game addon released

2016-06-21 Thread Ric Sherlock
I've added a Wd-based UI to the Rosetta code task 2048 engine and released it as an addon. Install via the Package Manager Run using: load 'games/2048' or load the desired UI directly load 'games/2048/ui_wd' load 'games/2048/ui_console' Enjoy! --

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Ric Sherlock
21, 2016 at 8:10 PM, Rob Hodgkinson wrote: > Very nice Ric ! > Maybe also include a View/Code option (obviously no secret, as its on > rosettacode.org <http://rosettacode.org/>). > > Regards Rob > > > > On 21 Jun 2016, at 5:54 PM, Ric Sherlock wrote: > > &

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Ric Sherlock
t;http://rosettacode.org/>). > > > > Regards Rob > > > > > > > On 21 Jun 2016, at 5:54 PM, Ric Sherlock wrote: > > > > > > I've added a Wd-based UI to the Rosetta code task 2048 engine > > > <http://rosettacode.org/wiki/2048#J&

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Ric Sherlock
Thanks Brian. Your edit will be in the next release. Cheers, On Wed, Jun 22, 2016 at 7:06 AM, Brian Schott wrote: > Ric, > > I really appreciate your coding and sharing this game. > I especially have benefitted from studying the console version because it > leaves the history on the screen and

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Ric Sherlock
the "up" direction, the result is: > > 4 > 2 > > Where currently your J implementation gives: > > 2 > 4 > > There are other differences, of course (J does not yet support the > arrow keys, for example). > > The fix looks straightforward. > > T

Re: [Jprogramming] New 2048 game addon released

2016-06-21 Thread Ric Sherlock
e HJKL in the same fashion. Implementing > either of those and providing a caption hint might be a way to go. > > Thanks, > > -- > Raul > > > On Tue, Jun 21, 2016 at 5:18 PM, Ric Sherlock wrote: > > Thanks Raul, > > You're right about the merging behaviour. I th

Re: [Jprogramming] Performance of fork vs train

2016-06-22 Thread Ric Sherlock
This isn't to do with forks vs trains per se. It is about J working better on (big) chunks rather than small ones. Using & or @ rather than &: or @: causes the verb to the left to operate on chunks that are a size determined by the rank of the verb to the right. Using @: or &: causes the verb to th

Re: [Jprogramming] How many years did each person live?

2016-06-28 Thread Ric Sherlock
Here is a reasonably concise one but I suspect not your preferred version f1=: (, {: -&.(".@>) {.)"1 f1 E ┌┬───┬┬─┐ │1809│Philip St. George Cooke│1895│86 │ ├┼───┼┼─┤ │1836│Flora Cooke Stuart │1923│87 │ ├┼─

Re: [Jprogramming] How many years did each person live?

2016-06-29 Thread Ric Sherlock
...@forums.jsoftware.com] On > Behalf Of Ric Sherlock > Sent: Tuesday, June 28, 2016 9:41 PM > To: Programming JForum > Subject: Re: [Jprogramming] How many years did each person live? > > Here is a reasonably concise one but I suspect not your preferred ver

Re: [Jprogramming] An easy one

2016-07-04 Thread Ric Sherlock
How's this? *//.~ q: 4200 8 3 25 7 On Tue, Jul 5, 2016 at 9:46 AM, Kip Murray wrote: > Consider > > q: 4200 > 2 2 2 3 5 5 7 > > How would you "reduce" this to 8 3 25 7 ? > Write the verb red: > > red q: 4200 > 8 3 25 7 > > --Kip Murray > > > > -- > Sent from Gmail Mobile > ---

Re: [Jprogramming] New 2048 game addon released

2016-07-04 Thread Ric Sherlock
gt;count NB. this is after the "simulation" > NB. repeat? > ) > > I am surprised at the apparently poor behavior of The Corner Strategy in my > simulation and am wondering if I have something wrong. > By poor behavior, I mean that the Count only gets to ab

Re: [Jprogramming] How many years did each person live?

2016-07-07 Thread Ric Sherlock
, 2016 1:34 AM > To: programm...@jsoftware.com > Subject: Re: [Jprogramming] How many years did each person live? > > > > Ric, I guess it is like most issues. You don't realize that you don't > like how you did something until you try to do something else w

Re: [Jprogramming] How long did the marriages last?

2016-07-11 Thread Ric Sherlock
Let's say you determine the length of the 3 marriages are 10 14 17, then you can amend NEW as follows: (<&> 10 14 17) ( wrote: > I have put married pairs together. The 4th column has the date for each of > the three marriages. I can get the length of their marriages but I can't > seem to insert

Re: [Jprogramming] How long did the marriages last?

2016-07-11 Thread Ric Sherlock
> > -Original Message- > From: Programming [mailto:programming-boun...@forums.jsoftware.com] On > Behalf Of Ric Sherlock > Sent: Monday, July 11, 2016 3:46 AM > To: Programming JForum > Subject: Re: [Jprogramming] How long did the marriages last? > > Let's say

Re: [Jprogramming] Stats/Base/Univariate Addon -- was: [Jchat] common mean example ...

2016-09-01 Thread Ric Sherlock
1.5 decades old > ... > > I'm directing this post especially (but not exclusively) to > > - Chris Burke and > - Ric Sherlock > > as from looking at the "trunk" it seems that these gentlemen have been the > sole maintainers of the '/addons/stats/base/

Re: [Jprogramming] Amending Sequential Rows

2016-11-08 Thread Ric Sherlock
Hi Skip, The document that I found filling this role for me was the J Reference Card linked on the Getting Started page of the wiki. I used these pages both to find the functionality I was looking for to solve an immediate need, but also to i

Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-05 Thread Ric Sherlock
I don't think that is a bug. Just a parsing issue. Is it 1 string with an escaped single quote or 2 strings (if you use the space) Much like <;._2 0 2 3 0 2 4 4 3 2 versus <;._2 ] 0 2 3 0 2 4 4 3 2 On Tue, Dec 6, 2016 at 11:44 AM, Brian Schott wrote: > Perhaps, this is the wrong place to ask t

Re: [Jprogramming] in function which beats the benchmark

2016-12-06 Thread Ric Sherlock
list1=: (i. 10e6) list2=: (1e6 + i. 9e6) 10 (6!:2) 'list2 e. list1' 0.0412252 10 (6!:2) '(1e6 + i. 9e6) e. (i. 10e6)' 0.20568 i5-4300U @ 1.90/2.5 GHz Taking the list creation out of the timing makes a significant difference. On Wed, Dec 7, 2016 at 9:51 AM, Henry Rich wrote:

Re: [Jprogramming] j805 installation experience on ubuntu

2016-12-21 Thread Ric Sherlock
I have a similar problem with an older Ubuntu 14.04 machine. I installed using the tar.gz archive and then used install 'qtide' to install the Qt IDE. When I try to run it I get: "/opt/j64_805/bin/libjqt.so" "could not resolve: state_run: Cannot load library /opt/j64_805/bin/libjqt.so: (libQt5Web

Re: [Jprogramming] Newbie frustration

2017-04-02 Thread Ric Sherlock
I think the key issues here is (as Henry suggests) that control words are only meaningful inside an explicit definition. The following defines an anonymous explicit verb to contain your control structure. It should work... 3 :0 '' k=. 0 while. k<: 1e2 do. k=. k+1 end. ) On Mon, Apr 3, 2017 a

Re: [Jprogramming] type/domain of an argument

2017-04-03 Thread Ric Sherlock
If you install the 'general/misc' addon using Package Manager there is a script (validate.ijs) that provides many tools for testing type/structure including: NB.* inrange v (low, high) inrange data NB.* isbalanced v pair isbalanced string NB.

Re: [Jprogramming] type/domain of an argument

2017-04-03 Thread Ric Sherlock
Sorry the link to Package Manager should have been: http://code.jsoftware.com/wiki/JAL/Package_Manager On Tue, Apr 4, 2017 at 8:48 AM, Ric Sherlock wrote: > If you install the 'general/misc' addon using Package Manager > <http://code.jsoftware.com/wiki/JAL/Package_Manager/

Re: [Jprogramming] indexed read doesn't work with /dev/urandom

2017-04-17 Thread Ric Sherlock
You may find the following thread from the forum of interest: http://www.jsoftware.com/pipermail/programming/2013-March/031870.html On Tue, Apr 18, 2017 at 5:33 PM, bill lam wrote: > 1!:x cannot read non regular files.try > 2!:0'cat /dev/...' > > > > On 18 Apr, 2017 1:13 pm, "Xiao-Yong Jin" wr

Re: [Jprogramming] Location of "readimg"

2017-05-09 Thread Ric Sherlock
When I start a j805 jconsole on Windows 7, then load 'ide/qt/qtlib' I can successfully read and write png files using readimg_jqtide_ and writeimg_jqtide_, but if I try and read a jpeg image file, I also get an empty matrix of shape 0 0 that Devon reports above. load 'ide/qt/qtlib' $readimg_jqtide

Re: [Jprogramming] Location of "readimg"

2017-05-09 Thread Ric Sherlock
Hi Bill, I have the same versions of all packages as you on both Linux and Windows. On Linux I can successfully read and write jpg and png. On Windows I can read and write png, but not jpg. readimg_jqtide_ 'toucan.png' NB. works fine on Windows & Linux readimg_jqtide_ 'toucan.jpg' NB. works on L

Re: [Jprogramming] Location of "readimg"

2017-05-10 Thread Ric Sherlock
Hi Bill, Just to add that I get the same behaviour you describe on win-xp with jqt and jconsole on Windows 7. On Wed, May 10, 2017 at 7:02 PM, bill lam wrote: > I can duplicate the behavior on win-xp. reading jpg was ok on jqt but > failed on jconsole. > > I think the issue is loading jqt.dll u

Re: [Jprogramming] Slideshow

2017-05-21 Thread Ric Sherlock
Hi Devon, You might look at the image Qt Demo (Help|Studio|Qt Demos...) for some examples for displaying images in forms. There are other demos there that may be of use too. There are some examples of simple gui apps on Rosetta code, eg: http://rosettacode.org/wiki/Simple_windowed_application#J ht

Re: [Jprogramming] Implementing a carry function

2017-05-22 Thread Ric Sherlock
While your approach is certainly achieving your objective of helping you learn the ins and outs of J, it doesn't seem to be the simplest or quickest way to solve the PE13 problem. Maybe worthwhile taking a step back? On Mon, May 22, 2017 at 9:50 PM, Lafras Uys wrote: > Hi, > > I am working thro

Re: [Jprogramming] Better documentation for wd?

2017-05-24 Thread Ric Sherlock
The simple examples that Bob mentioned are the best place to start. There are examples of more complex forms built using wd in a number of addons for example: load 'math/eigenpic' load 'math/deoptim/demo/eg_deoptim.ijs' On Thu, May 25, 2017 at 5:34 AM, robert therriault wrote: > Hi Devon, > >

Re: [Jprogramming] argument for under

2017-05-30 Thread Ric Sherlock
Hi Brian, Not sure if I've understood exactly what you're trying to accomplish, but the following seems to give the same result as above and enables the 1 to be an argument 1 ([: ;/ |.) i.5 4 3 HTH Ric On Tue, May 30, 2017 at 11:00 PM, Brian Schott wrote: > The following expression accomplis

Re: [Jprogramming] argument for under

2017-05-30 Thread Ric Sherlock
Note that you can simplify further ... ;/ 1 |. i.5 4 3 ;/ 1 |."_1 i.5 4 3 ​The brackets and [ ] don't serve any purpose.​ On Wed, May 31, 2017 at 1:27 AM, Brian Schott wrote: > Raul and Ric, > > Yes, the ;/ is only for illustrative purposes. > > So the pair of results I need a much simpler th

Re: [Jprogramming] Writing dyadic function with left/right parameters swapped

2017-06-03 Thread Ric Sherlock
I would write the original as: z ([ #~ 0 1 0 -:"1 {) 1 0 1 0 1 0 3 4 5 ​Then to reverse the arguments you could do one of the following: 1 0 1 0 1 0 ([ #~ 0 1 0 -:"1 {)~ z 3 4 5 1 0 1 0 1 0 (] #~ 0 1 0 -:"1 {~) z 3 4 5 On Sun, Jun 4, 2017 at 1:45 PM, Michael Rice wrote: >z

Re: [Jprogramming] Empty lists?

2017-06-08 Thread Ric Sherlock
Note the addon 'general/misc/validate' contains the verb isempty. isempty 0: e. $ On Fri, Jun 9, 2017 at 3:15 PM, Ian Clark wrote: > Henry, I absolutely agree. > > Only last night I was thinking NuVoc lacked an in-depth treatment of empty > lists (/tables) – and how it was a serious omission

Re: [Jprogramming] What is the function of the folder: ~user/J64-805-user/snap ?

2017-07-07 Thread Ric Sherlock
Hi Ian, My understanding is that this folder contains snap shots of files/projects that are created as a backup. You can set the number of Snap shots to keep in the Qt Ide configuration file (see Edit|Configure|Qt Ide) You can compare the currently open version of script to older versions using Scr

[Jprogramming] Covariance / Correlation matrix

2017-07-12 Thread Ric Sherlock
The current verbs for calculating covariance and correlation in the stats/base/multivariate.ijs script, are dyadic and designed to calculate the cov/corr between 2 variables e.g. load 'stats' X=: 1 1 1 1 2 2 2 2 3 3 3 3 Y=: 1 2 2 3 5 5 6 7 10 11 11 12 Z=: 1 1 2 2 4 6 5 4 8 7 9 10 X cov Y

Re: [Jprogramming] plot with two windows?

2017-07-14 Thread Ric Sherlock
Esa has already shown an example of how to create independent plots. The following wiki page also shows an example of displaying multiple independent plot windows as well as multiple plots on a form. http://code.jsoftware.com/wiki/Plot/Class On Fri, Jul 14, 2017 at 9:41 PM, bill lam wrote: > plo

Re: [Jprogramming] (no subject)

2017-07-14 Thread Ric Sherlock
I suppose this depends on what "reset" means exactly. You can run the following command to get rid of existing name definitions in the base locale clear '' But it is certainly not the same as a new J session. It might be useful to explain why you might want to "reset a jqt session". Regards, Ric O

Re: [Jprogramming] Covariance / Correlation matrix

2017-07-15 Thread Ric Sherlock
ddition to the suggested changes. (The speed differences are less prior to the avx improvements in 806) On Thu, Jul 13, 2017 at 12:42 PM, Ric Sherlock wrote: > The current verbs for calculating covariance and correlation in the > stats/base/multivariate.ijs script, are dyadic and design

Re: [Jprogramming] Everyone giving dollars to random others

2017-07-27 Thread Ric Sherlock
Note that 1e6 ?@# 1e3 and 1e6 ?@$ 1e3 are both optimised compared to ? 1e6 # 1e3 10 timespacex '?100#1000' 0.0230934 1.67786e7 10 timespacex '100?@#1000' 0.0176543 8.39002e6 10 timespacex '100?@$1000' 0.0186202 8.39002e6 On Fri, Jul 28, 2017 at 10:36 AM, 'Mike Day' vi

Re: [Jprogramming] How to enclose two columns

2017-08-27 Thread Ric Sherlock
Depends if you really want the resulting boxed items to have shape 1 4 or not. $&.> <"2|:"2 >BB ┌───┬───┐ │1 4│1 4│ └───┴───┘ If not then I'd probably go with one of these: ;&.> BB ┌───┬───┐ │0 2 4 6│1 3 5 7│ └───┴───┘ or ;L:0 BB ┌───┬───┐ │0 2 4 6│1 3

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Ric Sherlock
Hi Harvey, I haven't used it but the 'debug/tte' addon available in Package Manager has the following description: Addon: tte is an adverb to "explicate" a given tacitly-defined verb by generating an explanatory explicit definition from the given tacit definition. The result is a working verb which

Re: [Jprogramming] Overflow, underflow, floats

2017-09-20 Thread Ric Sherlock
My memory of grappling with the "how to handle missing data" issue in APL and J was that the most complete solution was to have a separate boolean array of the same shape as the data array that identified missings. This is certainly a clunkier approach from the user's POV compared to R, but is argu

Re: [Jprogramming] Tacit Expressions with Explicit J Syntax

2017-09-28 Thread Ric Sherlock
Hi Erling, Just want to suggest that statements like "we recognized tacit J is not useful" seem a little premature unless "we" is the royal "we" i.e. "I". Even then I suspect a more accurate statement would be "I don't see the benefits of tacit J". So far my understanding of your position is that

Re: [Jprogramming] Splitting an Array into several arrays

2017-10-21 Thread Ric Sherlock
Jon, The following assigns each of the data points to a group, then boxes those groups using key. assignGrp=: +/\@(* #) I. i.@#@] group=: assignGrp wrote: > Hi, > > What I am really after is a verb that splits by percentage. To give a > concrete uses case: > I have a dataset, which I wish

Re: [Jprogramming] J strengths?

2017-11-29 Thread Ric Sherlock
I agree there are some J solutions on RC that could be viewed as (or are) rather incomprehensible. I'm not sure there is a single consensus of what makes a great RC contribution though. Some argue that it should be the most natural solution for the language, others the most concise or the fastest.

[Jprogramming] Advent of code, Day 5 (spoilers probable)

2017-12-05 Thread Ric Sherlock
Did anyone come up with a nice Jish solution for this? Mine (see below) ended up being very scalar. countJumps=: 3 :0 count=. idx=. 0 offsets=. y while. (0 <: idx) *. (idx < #offsets) do. count=. count + 1 idx_new=. idx ([ + {) offsets offsets=. idx (1 + {)`[`]

Re: [Jprogramming] Advent of code, Day 5 (spoilers probable)

2017-12-05 Thread Ric Sherlock
27;s that > (though it also took over 70 times as many steps to complete.) > > That said, I should perhaps note that my leaderboard score is 0 - I'm > waiting plenty of time before trying these things. > > -- > Raul > > On Tue, Dec 5, 2017 at 5:05 PM, Ric Sherlock wro

Re: [Jprogramming] Advent of code, Day 4 (spoilers!)

2017-12-05 Thread Ric Sherlock
And mine: MyInput=: <;._2 freads '~AoC/2017/aoc04_input.txt' isValidPassPhrase=: (#@~. = #)@;: isValidPassPhrase=: (#@~. = #)@:(/:~&.>)@;: +/ isValidPassPhrase&> MyInput On Wed, Dec 6, 2017 at 1:11 PM, Raul Miller wrote: > Here were my day fours: > > valid=: (-: ~.)@;: > valid=: (-: ~.)@

Re: [Jprogramming] Advent of code, Day 5 (spoilers probable)

2017-12-06 Thread Ric Sherlock
Yes that's more like what I was hoping for. Very nice Arie! On Thu, Dec 7, 2017 at 11:29 AM, Arie Groeneveld wrote: > Nice Jish like? > > (([+{);>:@{`[`]})&>/ ::]^:a:@(0&;) 0 3 0 1 _3 > > > > Op 05-12-17 om 23:05 schreef Ric Sherlock: > >> Did

Re: [Jprogramming] Advent of code, Day 5 (spoilers probable)

2017-12-06 Thread Ric Sherlock
I don't think there is a "bug" in J. It is just that the sentence solution doesn't give the correct answer to the problem as specified, because J interprets index _1 as wrapping back around round rather than as an error. The problem specification is that if the index is less than 0 then the solutio

Re: [Jprogramming] Splitting an Array into several arrays

2017-12-15 Thread Ric Sherlock
──┘ > >group2 > (+/\@(* #) I. i.@#@]) f > ] > I was surprised at how neat f turned out when I wrote an explicit > definition of my version of you way to group the numbers. > > Linda > > > -Original Message- > From: Programming [mailto:progra

Re: [Jprogramming] Splitting an Array into several arrays

2017-12-16 Thread Ric Sherlock
2 'ABCDEFGHIJKLMN' ┌─┬─┬┐ │ABCDE│FGHIJ│KLMN│ └─┴─┴┘ 0.35 0.3 0.3 f 'ABCDEFGHIJKLMN' |domain error: f Thanks, -- Raul On Sat, Dec 16, 2017 at 12:14 AM, Ric Sherlock wrote: > Note that group2 and f are not equivalent. > > On 16/12/2017 00:0

Re: [Jprogramming] Splitting an Array into several arrays

2017-12-16 Thread Ric Sherlock
> you're talking about. > > Perhaps: > >0.35 0.3 0.3 group2 'ABCDEFGHIJKLMN' > ┌─┬─┬┐ > │ABCDE│FGHIJ│KLMN│ > └─┴─┴┘ >0.35 0.3 0.3 f 'ABCDEFGHIJKLMN' > |domain error: f > > Thanks, > > -- > Raul > > >

Re: [Jprogramming] How do I format a timestamp from the past?

2018-01-22 Thread Ric Sherlock
If you are looking for code to format dates and/or times *now* then the 'format/datefmt' and 'types/datetime' addons both have functionality that might be useful to you. load 'types/datetime' ', D MMM, ' fmtDate toDayNo 6!:0'' Tuesday, 23 Jan, 2018 Cheers, On Tue, Jan 23, 2018 a

Re: [Jprogramming] File Cleanup

2018-02-21 Thread Ric Sherlock
Another suggestion using some of J's in-built utilities dat=: freads 'yourfile.txt' labels=: <@(' '&taketo);._2 dat numbers=: _ ". (' '&takeafter);._2 dat HTH Ric On Wed, Feb 21, 2018 at 9:57 PM, 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > txt here is a set of lines from y

Re: [Jprogramming] File Cleanup

2018-02-21 Thread Ric Sherlock
Or using the tables/dsv addon: load 'tables/dsv' dat=: makenum ' ' readdsv 'yourfile.txt' Note that although they're boxed the numbers are actually numeric. To split them you could do: labels=: {."1 dat numbers=: > }."1 dat On Wed, Feb 21, 2

Re: [Jprogramming] File Cleanup

2018-04-04 Thread Ric Sherlock
Using the English-only file rather than the file you link to above (which is all languages and seems to be 3 times as big as the examples you show) load 'tar' timespacex ' labels=: }. <@('' ''&taket

Re: [Jprogramming] Scatterplot

2018-04-14 Thread Ric Sherlock
plot is documented on the J wiki: http://code.jsoftware.com/wiki/Plot How best to read/parse your 2-column file will depend on the actual format. Assuming the fields are separated by one or more spaces the following would work: data=: _999 ". > cut;._2 freads 'myfile.txt' 'point; pensize 2

Re: [Jprogramming] My idea about Note construction

2018-07-25 Thread Ric Sherlock
Hi Sergey, Your version of Note will break the current dyadic design of Note as described in the stdlib.ijs script (see extract below) http://www.jsoftware.com/wsvn/base8/trunk/main/main/stdlib.ijs Currently the dyadic form causes Note to render the rest of the current line as a "comment". Your ve

[Jprogramming] JAL stats/base permutations and combinations

2018-08-25 Thread Ric Sherlock
Hi all, I've made some changes , before I release them I wanted to check that no-one has any objections or suggestions for improvement? https://github.com/jsoftware/stats_base Summary: * Add "with replacement" versions of `comb` and `perm`. * Use more performant (less concise) version of `per

Re: [Jprogramming] JAL stats/base permutations and combinations

2018-08-26 Thread Ric Sherlock
Regarding the name of dyadic perm, it seems to me that permutations of combinations of y are pretty much just permutations so I'm pretty happy with the current naming. We could use Brian's "permutations of i.y items taken x at a time" rather than the current "permutations of size x from i.y", if t

Re: [Jprogramming] api/expat

2018-08-29 Thread Ric Sherlock
Not sure how helpful this is but the original implementation of the tables/taraxml addon used the SAX model which looks like what Expat library uses. The old code is still available on Github, the following link is to the commit that moved to xslt from

Re: [Jprogramming] JAL stats/base permutations and combinations

2018-08-29 Thread Ric Sherlock
These suggested changes to the stats/base addon are now available from JAL along with some support for rank and rank correlation. https://github.com/jsoftware/stats_base On Mon, Aug 27, 2018 at 8:26 AM Ric Sherlock wrote: > Regarding the name of dyadic perm, it seems to me that permutati

Re: [Jprogramming] SHA-256

2018-09-03 Thread Ric Sherlock
Note that this uses Qt libraries from the 'ide/qt' addon. This functionality is also available from a console session: load 'ide/qt/qtlib' However the gethash verb is loaded in the 'z' locale if using the IDE, whereas running the command above in a console session will define the gethash verb i

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-09 Thread Ric Sherlock
The following is a simple refactoring of the original: pmt=: {: * 1&{ ((% <:)@(^~ >:) * ]) 1200 %~ {. pmt 5.75 240 12500 87.7604 The steps to get there went something like this: pmt =: 3 : 0 ' r t b'=. y d=. (1 + r % 1200) ^ t b*(r % 1200) * d % d - 1 ) pmt=: 3 : 0 'r t b'=. y b * r (

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-09 Thread Ric Sherlock
Note the 2nd to last "step" is superfluous - the same as the previous line with slightly different spacing! On Mon, Sep 10, 2018 at 6:11 PM Ric Sherlock wrote: > The following is a simple refactoring of the original: > >pmt=: {: * 1&{ ((% <:)@(^~ >:) * ]) 1200

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-10 Thread Ric Sherlock
y Verizon, Samsung Galaxy smartphone > > > ---- Original message > From: Ric Sherlock > Date: 9/10/18 2:11 AM (GMT-05:00) > To: Programming JForum > Subject: Re: [Jprogramming] Tacit form: How to handle intermediate > > The following is a simple refactoring of the original:

Re: [Jprogramming] Tacit form: How to handle intermediate

2018-09-10 Thread Ric Sherlock
PM Linda Alvord wrote: > Now can someone, not Ric, write his version explicitly. > > PMT=: 13 : > Linda > > Sent from my Verizon, Samsung Galaxy smartphone > > > Original message > From: Ric Sherlock > Date: 9/10/18 7:04 PM (GMT-05:00) > T

Re: [Jprogramming] (v0`v1`v2)} y

2018-09-17 Thread Ric Sherlock
A while back I asked why (v0`v1`v2)} y was not defined as (v0 y) (v1 y)} (v2 y) In case it is of interest, Roger's response was: The current defn makes it possible to define f=: v0`v1`v2} such that the monad f uses m} monad

Re: [Jprogramming] J807 released

2018-10-09 Thread Ric Sherlock
I think the fix for the original problem was made, but there was a typo. That typo has now been fixed and a new version of the base library is now available that has a working tar.ijs. On Wed, Oct 10, 2018 at 7:47 AM David Mitchell wrote: > I agree. I had hoped it would have been fixed after

Re: [Jprogramming] Shuffle and deal 4 bridge hands

2018-10-14 Thread Ric Sherlock
I haven't followed this thread very closely so am not sure how useful the following will be, but this Rosetta Code link may be of interest. http://rosettacode.org/wiki/Playing_cards#J On Sun, Oct 14, 2018 at 12:47 PM Linda Alvord wrote: > > This should now work in most J environments. > > F=:52$

Re: [Jprogramming] J701 iPod strange behavior

2018-10-25 Thread Ric Sherlock
For now I've changed the text on the wiki page to clarify that `open` only applies to JQt. I've also added a link to the page of the User manual that describes the Standard Library in more detail. On Fri, Oct 26, 2018 at 12:13 PM 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > I'

Re: [Jprogramming] Sub-string Matching

2018-10-26 Thread Ric Sherlock
Alternatively: (<0 0) ssmb&> a 0 0 0 0 0 (<0 0) ssmb&> b 0 0 1 0 0 0 On Sat, Oct 27, 2018 at 10:25 AM Raul Miller wrote: > You might want to try something like: > >0 0 ssmb S:0 a > 0 0 0 0 0 >0 0 ssmb S:0 b > 0 0 1 0 0 0 > > Thanks, > > -- > Raul > On Fri, Oct 26, 2018 at 5:14 PM S

  1   2   3   4   >