[Jprogramming] Non-scalar Newton-Raphson

2016-02-13 Thread Louis de Forcrand
I’ve been trying to write a conjunction that will find the zeros to a function using the Newton-Raphson method. The simplest way to do this is probably: English: x_n+1 = x_n - f ( x_n ) / f ‘ ( x_n ) J: eznewt=: 2 : ‘ ( - u % u D.1 ) ^: n ‘ This works fine for scalar -> scalar functions, but w

Re: [Jprogramming] Non-scalar Newton-Raphson

2016-02-13 Thread Louis de Forcrand
ind no use of A in the expression you are describing. > > Can you look over what you wrote and decide if it is what you meant to say? > > Thanks, > > -- > Raul > > On Sat, Feb 13, 2016 at 10:50 AM, Louis de Forcrand wrote: >> I’ve been trying to write a conj

Re: [Jprogramming] Non-scalar Newton-Raphson

2016-02-13 Thread Louis de Forcrand
t is >> >> v_{n+1} = v_n - f(v_n) * f'(v_n) / |f'(v_n)|^2 >> >> or >> >> vsnewt =: 2 : '(- u * [: (% +/@:*:) u D.1)^:n' >> >> +/@:*: vsnewt (<5) 3 4 >> 34 >> 1.52 >> 0.751 >> 0.375 0.5 &

Re: [Jprogramming] Non-scalar Newton-Raphson

2016-02-15 Thread Louis de Forcrand
nd it is getting pretty close to what you are looking > for. > > Ben > > > From: Programming [programming-boun...@forums.jsoftware.com] on behalf of > Louis de Forcrand [ol...@bluewin.ch] > Sent: Saturday, February 13, 2016 16:50 > T

Re: [Jprogramming] A plane rotation

2016-02-18 Thread Louis de Forcrand
To continue with the rotation challenges, write a verb that rotates a linear polynomial (coeffs in x) by 0 {:: y with a centre of 1 {:: y: 1 2 linrot 1p1 ; 0 1 1 2 1 2 linrot 1r2p1 ; 0 1 1 _0.5 1 2 linrot 1p1;1 1 _3 2 My take: linrot=: ({: %. 1 ,. {.)@rotposmat rotposmat=: centre + j./@

Re: [Jprogramming] A plane rotation

2016-02-19 Thread Louis de Forcrand
and in the third it is 1 1 . --Kip >>>> >>>> On Thursday, February 18, 2016, Raul Miller >> > wrote: >>>> >>>>> I'm not quite sure I follow what you are doing here. >>>>> >>>>> Shouldn't 2p1

[Jprogramming] Formatting tables

2016-02-20 Thread Louis de Forcrand
From what I read in the dictionary, all formatting primitives format tables and higher rank arrays into a frame of 1-cells. Is there a way to format a table using LFs between rows, so as to be easy to write to a file? I tried formatting a (huge) rank-2 array of coordinates for gnuplot using farr

Re: [Jprogramming] Formatting tables

2016-02-20 Thread Louis de Forcrand
Thank you so very much. That was so simple I feel kind of dumb now... Thanks again! Louis > On 21 Feb 2016, at 00:48, Henry Rich wrote: > > , (":!.20 array) ,. LF > > Henry Rich > >> On 2/20/2016 6:39 PM, Louis de Forcrand wrote: >> From what I rea

Re: [Jprogramming] Formatting tables

2016-02-21 Thread Louis de Forcrand
This is suitable for transfer to > file. For gnuplot two successive blank lines separate the index groups. > >rank =: #@:$ >to_literal=: ([:,/,.&LF)"2^:(0>.<:@:rank)@:": NB. as a dyad x is x of ": >to_literal i. 2 3 4 > 0 1 2 3 > 4 5 6 7 >

Re: [Jprogramming] Am I understanding m/y ?

2016-02-22 Thread Louis de Forcrand
One use of gerund insertion is continued fractions: http://www.wolframalpha.com/input/?i=continued+fraction+golden+ratio phi = 1 + 1 % 1 + 1 % 1 + … +`%/ 50 # 1 1.61803 which is the golden ratio. I believe this was i

Re: [Jprogramming] Am I understanding m/y ?

2016-02-24 Thread Louis de Forcrand
I believe this works on gerunds of length >= 2: foldl2=: 1 : '{.`([: $: _2&}. , m ugly)@.(*@<:@#)' ugly=: 1 : '({:y) (m {~ (#m) | _3 + #y)`:6 (_2{y)' I don't know how to write the ugly part tacitly. It doesn't work with suffix (\.) either. +`* foldl2 >: i.7 209 +`*`+ foldl2 >: i.5 30

Re: [Jprogramming] Imaginary Squares

2016-02-28 Thread Louis de Forcrand
the square of your previous magnitude. Louis > On 28 Feb 2016, at 16:51, Louis de Forcrand wrote: > > As far as I can tell, Kip's version is correct. Starting at 0j1, it can be > simplified as: > >> :@*:@i. 9 > 1 2 5 10 17 26 37 > > My version was: > &g

[Jprogramming] Inverses

2016-03-02 Thread Louis de Forcrand
The way J handles inverses to functions is quite unique and, while not always very useful, can lead to compact but very descriptive code: +/&.:*: NB. distance +&.^. NB. multiplication u&.(a.&i.) NB. u applied to y’s indices in a., then indexed out of a. etc. However, some less easily inver

Re: [Jprogramming] Inverses

2016-03-02 Thread Louis de Forcrand
> > 1 2 3 0&{ 'ABCD' > BCDA > 1 2 3 0&{inv 'ABCD' > DABC > > Then, the inverse reverses the permutation. > > Does that help? > > Thanks, > > -- > Raul > > >> On Wed, Mar 2, 2016 at 7:39 PM, Louis de Forcrand

Re: [Jprogramming] Inverses

2016-03-02 Thread Louis de Forcrand
on what primitives have inverses, but it seems that you have > found some combinations not listed there. Would you be willing to add what > you have found to that page? > > Henry Rich > >> On 3/2/2016 7:39 PM, Louis de Forcrand wrote: >> The way J handles invers

Re: [Jprogramming] Inverses

2016-03-03 Thread Louis de Forcrand
g? This would hardly be the first > occasion where I've overlooked something obvious. (Could you provide a > working example of what you were suggesting?) > > Thanks, > > --- > Raul > > >> On Wed, Mar 2, 2016 at 9:02 PM, Louis de Forcrand wrote: >>

[Jprogramming] Fractions challenge

2016-03-06 Thread Louis de Forcrand
Try to write a verb or adverb(s) that can add, subtract, multiply, and divide two vectors of shape two which represent two exact fractions: 1 2 plus 3 4 5 4 1 2 minus 3 4 _1 4 1 2 times 3 4 3 8 1 2 divide 3 4 2 3 At first sight this may seem useless, as exact arith

Re: [Jprogramming] Fractions challenge

2016-03-06 Thread Louis de Forcrand
=: 1 : '(% +./)@((u/@:* |.) , */@])"1' > > > > > From: Louis de Forcrand mailto:ol...@bluewin.ch>> > To: programm...@jsoftware.com <mailto:programm...@jsoftware.com> > Sent: Sunday, March 6, 2016 12:31 PM > Subject: [Jprogramming] Fractions

[Jprogramming] Jsoftware dot com / papers

2016-03-06 Thread Louis de Forcrand
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 on the bibliography page on the wiki have dead links to it too. Louis -- For information a

Re: [Jprogramming] Jsoftware dot com / papers

2016-03-06 Thread Louis de Forcrand
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 on the >> bibliogra

Re: [Jprogramming] Feedback on beginner's code

2016-03-13 Thread Louis de Forcrand
Nice first program. I'm afraid pretty much all that there was to say about it has been said already, so all I'll add is my personal preferences for documentation. I skimmed through several of the included books, before settling on the actual Dictionary introduction. This is probably just personal,

[Jprogramming] Tree display of a boxed noun

2016-03-13 Thread Louis de Forcrand
Is there a foreign or a stdlib verb to display a boxed noun in tree form like verbs can be displayed? For example: mean=: +/ % # mean ┌─ / ─── + ──┼─ % └─ # Thanks, Louis -- For information about J forums se

Re: [Jprogramming] Tree display of a boxed noun

2016-03-13 Thread Louis de Forcrand
Thanks, but I'm looking for a similar representation for nouns (not verbs). I realise now that the title I gave this thread is misleading, as the argument to 5!:4 is in fact a boxed noun. What I am looking for is a prettier way to display a tree represented as a boxed noun. I could copy it down b

Re: [Jprogramming] Tree display of a boxed noun

2016-03-13 Thread Louis de Forcrand
Wow. That surpasses my expectations. Thanks a million! Louis > On 14 Mar 2016, at 01:19, Henry Rich wrote: > > Look at > > http://code.jsoftware.com/wiki/Essays/Tree_Display > > Henry Rich > > On 3/13/2016 7:41 PM, Louis de Forcrand wrote: >> Than

[Jprogramming] Tail recursion

2016-03-19 Thread Louis de Forcrand
Let t3 be a recursive verb equivalent to >:@(3&{.) : t3=: $:@}:`>:@.(3 = #) (>:@(3&{.) -: t3) i.1e3 1 (>:@(3&{.) -: t3) i.1e4 |stack error: t3 | (>:@(3&{.)-:t3)i.1 T3=: >:@(}:^:(-.@(3 = #))^:_) (>:@(3&{.) -: T3) i.1e3 1 (>:@(3&{.) -: T3) i.1e4 1 Most of the time (and t

Re: [Jprogramming] Tail recursion (bug hijack)

2016-03-19 Thread Louis de Forcrand
t; recursive2=: vr`v1@.v2 >> >> recursive i.20 >> >> I can accept that I am using $: wrong, but if vr is defined as what appears >> to be equivalent: >> >> vr =: $:@v0 >> >> then recursive2 -: recursive (no crash) >> >> Is there a speci

Re: [Jprogramming] Foreigns

2016-04-23 Thread Louis de Forcrand
I believe your original question was wether it was possible to remove the '' after a verb. This is called a niladic (like monadic/dyadic) verb in APL, but is not possible in J. If you wish to "fix" an argument to a verb, you can do so by creating a constant verb that returns the argument in que

Re: [Jprogramming] gotcha/mini bug with {.

2016-04-27 Thread Louis de Forcrand
({. -: 0&{) y I believe this holds for any y, except if: (0 = {.@$) yNB. the first dimension of y is empty Then, according to the dictionary, this holds for any y whatsoever: ({. -: 0 { 1 {. ]) y Louis > On 22 Apr 2016, at 22:30, 'Pascal Jasmin' via Programming > wrote: > > (1 {. ]) i

Re: [Jprogramming] Foreigns

2016-04-27 Thread Louis de Forcrand
I agree that niladic functions are dispensable. After all, since any (normal?) verb v returns a noun, a self-updating noun could simply be written as (v ''). It is an expression, but it evaluates to a noun and is enclosed in parens, so I don't see much of a difference. And simpler is usually bett

Re: [Jprogramming] divide if not zero

2016-05-06 Thread Louis de Forcrand
(0 = {:)`(%/ ,: {.)}@,: is another solution. It has the same effect as ([ * 0 = ]) + % * 0 ~: ] or %^:(~:&0)"0 in that it keeps the original number instead of replacing it by 0. As a side-note, I was surprised not to find special code associated with v1`v2}, especially if v2 has the form u ,: v. An

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Louis de Forcrand
(Unicode APL chars in this message! and a spoiler if you haven't yet found the solution!) I love showing off the APL (from the original book) solution for this to people who have heard nothing of array-based languages: V +.× ∊ ∨.= N ∘.| V which finds the sum of the numbers in the vector V whi

Re: [Jprogramming] divide if not zero

2016-05-06 Thread Louis de Forcrand
I see. So here the special code is implemented? 1e2 timespacex 'a=: c}a,:d=: a%b [ c=: 0 ~: b=: ?1e6#5 [ a=: ?1e6#5' 0.103524 6.71141e7 If I take the random generators out of the timer, then it is slightly faster and less space-hungry than the my previous expression: a=: ?1e6#5 b=: ?1e6

[Jprogramming] All unique permutations of a logical vector

2016-05-29 Thread Louis de Forcrand
Is there a faster (and relatively concise) way of generating (~.@:A.~ i.@!@#) b where b is a logical vector (of 0s and 1s)? There are obviously (+/ ! #) b vectors in the result, but I can't see any relation in their anagram indices: I.@(-:"1/~ ~.)@(A. ~i.@!@#) 1 1 1 0 0 0 1 6 7 24 25 30 3

Re: [Jprogramming] All unique permutations of a logical vector

2016-06-01 Thread Louis de Forcrand
Thanks! Those were exactly what I was looking for. Louis > On 29 May 2016, at 23:12, Louis de Forcrand wrote: > > Is there a faster (and relatively concise) way of generating > (~.@:A.~ i.@!@#) b > where b is a logical vector (of 0s and 1s)? > There are obviously (+/ ! #

[Jprogramming] Am I understanding m/y ?

2016-06-12 Thread Louis de Forcrand
Hi, There was some talk a while ago about the ambiguity of the dictionary about the direction of gerund insertion. Reading through the first pages of Iverson's Concrete Math Companion, I stumbled on a snippet of J that dates back to 2002 and was written by Iverson at the bottom of page 6: http:

[Jprogramming] All anagrams, ignoring reversal

2016-06-15 Thread Louis de Forcrand
Hi, How would you go about generating all unique permutations of a list, while counting each perm and its reversal as one? A perhaps clearer (but less efficient) way of doing this is generating all permutations and then removing (reversed) duplicates: allperms=: (A.&i.~ !) 4 NB. 4 is just an e

Re: [Jprogramming] challenge: dyad -. but removing the number of copies of x in y

2016-07-25 Thread Louis de Forcrand
Hi, My solution is based heavily on this: http://www.sudleyplace.com/APL/AnatomyOfAnIdiom.ahtml dfm0=: [ {~ [: ([ i. -.)&>/ ,&# <@$"0 1 [ /:@/:"1@i. , ,: ,~ dfm1=: [: ; {."1@-.&(,&<"_1 +/@(* +/\"1)@=) x=: 'cabd' [ y=: 'cbaab'

Re: [Jprogramming] challenge: dyad -. but removing the number

2016-07-26 Thread Louis de Forcrand
Excuse me, I seem to have misunderstood the problem. My versions begin deleting from the beginning; a simple fix would be dfm0&.|. Louis -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Gustafson's Unums Revisited

2016-08-20 Thread Louis de Forcrand
IMHO the only time it would actually be useful to distinguish between numerical datatypes is when using extended precision. Perhaps append an "x" to the last number of an extended precision array if all denominators are 1 (i.e. it is visually impossible to distinguish from an integer array). I'm

[Jprogramming] Jolfing

2016-08-20 Thread Louis de Forcrand
Hi everyone, Would this be the appropriate place for some Jolfing (J code golfing), or is there a better place for this? Thanks, Louis -- For information about J forums see http://www.jsoftware.com/forums.htm

[Jprogramming] Jolf

2016-08-20 Thread Louis de Forcrand
t; Source: http://www.jsoftware.com/forums.htm > > On Aug 20, 2016 3:35 PM, "Louis de Forcrand" wrote: > >> Hi everyone, >> >> Would this be the appropriate place for some Jolfing (J code golfing), >> or

Re: [Jprogramming] Jolf

2016-08-20 Thread Louis de Forcrand
N times, starting with an empty vector. Good luck, Louis > On 21 Aug 2016, at 00:49, Louis de Forcrand wrote: > > Alrighty then. > > Let’s start this off with a couple of rules: > - We can either count characters or tokens; I suggest tokens. > Either one should be counted on

[Jprogramming] Fwd: [Bug-apl] stacked rank operator

2016-08-24 Thread Louis de Forcrand
Y' '(P E X)U¨Q E Y' ∇ Hopefully the special characters go through OK. I wanted to know if you guys (and gals) think that R looks trustworthy. A note on the ;K in the lambda: this simply means that K is local to it. Thanks, Louis > Begin forwarded message: > > From: Louis de

Re: [Jprogramming] Jolf

2016-08-24 Thread Louis de Forcrand
you must strengthen the rules; the easiest way would be >> to add "no cheating is allowed." Otherwise, one can cheat easily [0] >> >> [0] >> >> >> >> >> >> On Sat, Aug 20, 2016 at 6:49 PM, Louis de Forcrand >> wrote: >>

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
Got this: cl=: [: {:"1 ] ([: ; lp&.>/"1)@]^:(*./@:~: {:@>@{:"1)^:_ lp lp=: [ ((-. (,: |.)@(_2&{.)) ; ])"2 1 ] ,"1 0 {:"1@[ {~ {:@] I.@:= {."1@[ Not particularly elegant or concise, but it works (G -: edges): ((, |."1) G) cl 1 1 2 4 5 6 7 8 9 10 11 12 13

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
the wrong versions in the last message: cl=: [: >@{:"1 ] ([: ; lp&.>/"1)@]^:(*./@:~: {:@>@{:"1)^:_ lp lp=: [ ((-. (,: |.)@(_2&{.)) ; ])"2 1 ] ,"1 0 {:"1@[ {~ {:@] I.@:= {."1@[ cls=: [: {:"1 ] ([: ; <@(lp&>/@]`(,:@])@.(= {

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
I was just wondering if 1 2 4 6 5 3 2 1 is considered a cycle since 2 is traversed twice. I would think not. Louis > On 25 Aug 2016, at 13:42, R.E. Boss wrote: > > It's not a directed cycle > > (1+i.26) /:~"1|: ({.,#)/.~ , edges > 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
I think the 2 at the beginning of your solution (1 _2_ 3 17 …) should be at the end. Cheers, Louis > On 25 Aug 2016, at 23:21, Raul Miller wrote: > > I am more than willing to believe that I have been careless and made a > mistake. I'm actually pretty talented at making mistakes. > > That sai

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
It seems I hadn’t fully understood the fact that the graph consisted of one and only one cycle. Thus my first solution is a little overkill for this problem, as it should work on any graph. Here’s another shorter one, probably similar to yours: cycle=: >@{:@(sol&>/@]^:(<:@#@[) (}. ; {.)) sol=:

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-02 Thread Louis de Forcrand
The best me and my father could come up with is: s=: [: e (<<_) p&.>/@,~ <"0 p=: ] , [ ,&.> ] #~ (< {.&>) (= >./)@:* #&>@] e=: }:@>@(#~ (= >./)@:(#&>))@> si=: [: e (<<_) pi&.>/@,~ <"0 pi=: ] , [ ,&.> ] {~ (< {.&>) (i. >./)@:* #&>@] Let v be a valid increasing subsequence. If n < {.v then n,v is

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-09 Thread Louis de Forcrand
Indeed lisL does return several results. I believe one verb I wrote returned all subsequences of maximal length, but the (much faster) version which is referred to by lisL only returns some longest subsequences. They should all be correct. Louis > On 09 Sep 2016, at 17:04, Raul Miller wrote:

Re: [Jprogramming] A Complaint with Format

2016-09-24 Thread Louis de Forcrand
You could also use sminput or stdin verbs to get character input, and, if necessary, cut on spaces. Then you'd have a character vector of the verb which you can later execute, and a character vector of the digits (with leading zeros). Louis > On 23 Sep 2016, at 22:12, Skip Cave wrote: > > I

Re: [Jprogramming] Learning Recursion

2016-09-29 Thread Louis de Forcrand
Try "tacitifying" rm. If you get stuck, you can use (13 :) , but a usual tacit definition of rm would be slightly different. I suggest you take a good look at the dictionary pages on trains and tacit verbs. Here's the way I would write rm as a tacit verb: rmt=: ] #~ (| i.@#) ~: <:@[ x rmt y x (

Re: [Jprogramming] Non-mutable arrays

2016-10-04 Thread Louis de Forcrand
I second Raul; the behaviour described is very counter-intuitive. Maybe add a third setting to 9!:53 which copies a at the start of a tacit verb involving in place operations? Also, what is the current (j804) behaviour when an in-place ammend fails? Since there's only one operation, if it fails

Re: [Jprogramming] Early assignment WAS: Non-mutable arrays

2016-10-05 Thread Louis de Forcrand
e to a name that is about to be reassigned) will apply >>> only for sentences executed from an explicit definition. That will >>> eliminate the most likely source of confusion, which is erroneous >>> sentences typed into the console during debugging and exploration. >&g

Re: [Jprogramming] Early assignment WAS: Non-mutable arrays

2016-10-05 Thread Louis de Forcrand
tion is in the unexecuted > part of the sentence. > > Henry Rich > >> On 10/5/2016 6:08 PM, Louis de Forcrand wrote: >> In >> N=: f N=: 1 2 3 >> If I understand correctly, N itself has no usecount. However, 1 2 3 does, >> and when it's assigned to N, its use

Re: [Jprogramming] stack error or private/public name collision

2016-11-05 Thread Louis de Forcrand
I must say this is very confusing. Shouldn’t any function that a) makes no use of any foreigns or ?, b) uses only local definition =. and c) does not access any global variables (or has shadowed them with a local definition) return the same result every time it is run with identical (same value)

Re: [Jprogramming] stack error or private/public name collision

2016-11-06 Thread Louis de Forcrand
> > Just to pick up on one thing I did see: The value of (g =: ]) is (]), a > primitive with no name, which is not the same as (g), a name. > > Henry Rich > >> On 11/5/2016 12:38 PM, Louis de Forcrand wrote: >> I must say this is very confusing. >> Shouldn’t a

Re: [Jprogramming] Amending Sequential Rows

2016-11-06 Thread Louis de Forcrand
sumpears=: +/@]^:[&.>~ (*. 1 = +/\"1)@:(=/@>) Does this do what you want? Louis Sent from my iPhone > On 07 Nov 2016, at 05:50, Skip Cave wrote: > > NB. I have the following array n consisting of 5 identical rows of boxed > pairs of integers: > > n > > ┌───┬───┬───┬───┬───┬───┬───┬───┬───

Re: [Jprogramming] stack error or private/public name collision

2016-11-07 Thread Louis de Forcrand
ons with the > requisite precision. > > From what I have seen, lack of experience with other languages is a benefit > for learning J. > > Henry Rich > > > On 11/6/2016 9:35 PM, Louis de Forcrand wrote: >> Thank you. I got the verb versus pro-verb probl

Re: [Jprogramming] stack error or private/public name collision

2016-11-07 Thread Louis de Forcrand
it depends on wether the name which is shadowed is a verb or not, as far as I can tell. Louis > On 08 Nov 2016, at 01:01, Raul Miller wrote: > > Because the name 'u' is a special name. One of six special names in > the language. > > -- > Raul > > >>

Re: [Jprogramming] Amending Sequential Rows

2016-11-08 Thread Louis de Forcrand
f=: (] dyax ywx)"_ 0 ind ind=: [: I. 2 =/\ ] NB. indices of 1st number in pairs dyax=: +:@{`[`]} NB. double y at x index ywx=: <^:3@] { [ NB. y without x index Take a look at the dictionary page for } (ammend) with gerunds (` expressions). In addition, a triply-boxed left argument to { simply rem

Re: [Jprogramming] How can I echo characters to JQT terminal window each time through a loop?

2016-12-17 Thread Louis de Forcrand
I believe echo is slightly different from smoutput: smoutput outputs to the J session, while echo outputs to stdout. This doesn't make a difference when *you*'re using JQt or Jconsole, but if Jconsole is started silently (which is possible right?) I think echo will output text while smoutput won

Re: [Jprogramming] How can I echo characters to JQT terminal window each time through a loop?

2016-12-18 Thread Louis de Forcrand
You're right. I was thinking of the stdout verb. Sorry! Louis > On 18 Dec 2016, at 01:05, bill lam wrote: > > No, echo and smoutput are synonyms. There are verbs stdout and stderr for > stdio. > > > > On 18 Dec, 2016 6:19 am, "Louis de Forcrand"

Re: [Jprogramming] Sequence Matching

2016-12-18 Thread Louis de Forcrand
match=: I.@E. match1=: (#~ 1 < #&>)@(]\ <@match"1 _ ]) NB. simple but slow match1s=: 4 : '(1<#&>r)#r=. (n i.s) { y <@match"1 _~ n=. ~.s=. x]\y' NB. faster on large arguments Perhaps adding parentheses in the right places may activate some special code for E."1 _. Louis > On 18 Dec 2016, at 22:

Re: [Jprogramming] J805 - install it! - for macOS Sierra, must edit sierra-fix.command

2016-12-20 Thread Louis de Forcrand
For the cd command in sierra-fix.command, I would say that cd $(dirname $0) would be better, since it would allow installation in any directory. I'm not a bash pro however, so someone might have to confirm that this works as intended. Louis > On 20 Dec 2016, at 18:07, Joey K Tuttle wrote: >

[Jprogramming] Strange 13 : '...' behavior

2016-12-27 Thread Louis de Forcrand
From: http://rosettacode.org/wiki/Hofstadter-Conway_$10,000_sequence JVERSION Engine: j805/j64/darwin Beta-12: commercial/2016-09-30T16:11:35 Library: 8.05.07 Platform: Darwin 64 Installer: J805 install InstallPath: /users/louisd

Re: [Jprogramming] Strange 13 : '...' behavior

2016-12-27 Thread Louis de Forcrand
(a@:a@:<: + ] a@:([ - a@]) <:)`1:@.(<:&2) > > > > - Original Message - > From: Louis de Forcrand > To: programm...@jsoftware.com > Sent: Tuesday, December 27, 2016 6:07 PM > Subject: [Jprogramming] Strange 13 : '...' behavior > > From

Re: [Jprogramming] Rules for inversing a user defined verb

2016-12-30 Thread Louis de Forcrand
Doesn't have much to do with verb inverses, but here's another (probably more efficient) way to solve your problem: NB. without inner vowels: woiv=: #~ -.@vowel +. adjsep NB. keep if not a vowel or if adjacent to a seperator vowel=: e.&'AEIOUaeiou' adjsep=: ((1 ,~ }.) +. 1 , }:)@sep NB. if to

Re: [Jprogramming] dyadic valence of v in u&.v ?

2017-01-01 Thread Louis de Forcrand
Or >:@#`(I.@[)`]} Louis > On 02 Jan 2017, at 02:16, 'Pascal Jasmin' via Programming > wrote: > > and, > > 0 0 1 0 0 1 >:@]^:["0 i.6 NB. passes original unchanged > > or as requested, > > 0 0 1 0 0 1 [`(>:@])@.["0 i.6 > > > > - Original Message - > From: 'Pascal Jasmin' via Prog

Re: [Jprogramming] Shifting an Array

2017-01-13 Thread Louis de Forcrand
A little late, but here's mine: v=: (<:3 3#:1 3 5 7)&(|.!.'x') Louis > On 09 Jan 2017, at 15:58, Henry Rich wrote: > > Better on big arrays: > > (2 _2 {."0/ _1 1) |.!.'x'"1 _ a > > This produces shape 2 2 3 4 which you could convert to shape 4 3 4 using (,/) > > Henry Rich > > >> On 1/9

Re: [Jprogramming] Tacit definition of infix similar to special gerund form of amend

2017-01-17 Thread Louis de Forcrand
f=: [ <@,:"1 -@#@[ ]\ ] Louis > On 17 Jan 2017, at 18:09, Mark Allen wrote: > > I have the following line of J: > > > _3 (<@:('key'&,:)\) 'arbitrary_string' > > ┌───┬───┬───┬───┬───┬───┐ > > │key│key│key│key│key│key│ > > │arb│itr│ary│_st│rin│g │ > > └───┴───┴───┴───┴───┴───┘ > > > I wo

Re: [Jprogramming] Tacit or Explicit

2017-01-21 Thread Louis de Forcrand
On the topic of f., one must be careful when using f. on a recursive verb (or one that uses another recursive verb). Louis > On 21 Jan 2017, at 16:22, Don Guinn wrote: > > When does it matter whether a statement is tacit or explicit or a mixture > of both? Not normally as the difference in per

Re: [Jprogramming] Tacit or Explicit

2017-01-22 Thread Louis de Forcrand
erb with >>>>> identical performance and viceversa. >>>>> >>>>> By the way, according to that notion, the verb - : + would be >>>>> explicit... Really? >>>>> >>>>> >>>>> On Saturday, Jan

[Jprogramming] 2D animation

2017-02-08 Thread Louis de Forcrand
Hi everyone, I've been looking into the Qt facilities available in J recently, and I read that 2D graphics are best done with gl2. I hacked together a simple program that displays a ball which bounces around the isidraw container. Having never really done any graphics-related programming, I us

Re: [Jprogramming] Hooked again

2017-02-12 Thread Louis de Forcrand
The two statements are not equivalent, but seem to produce the same result. I will see if I can find out why. Louis > On 12 Feb 2017, at 14:11, Lippu Esa wrote: > > Ok, thanks! I got it now. > > Esa > > > > Original message > From: 'Mike Day' via Programming > Date: 2/12

Re: [Jprogramming] Hooked again

2017-02-12 Thread Louis de Forcrand
The two statements are executing two different procedures which happen to be mathematically equivalent: u=: ((mp~ |:) (-"1 mean)) % # v=: (mp~ |:)@(-"1 mean) % # If (u -: v) A for a matrix A, then (((mp~ |:) (-"1 mean)) -: (mp~ |:)@(-"1 mean)) A. Let C=: A - B=: (E=: (m,m) $ 1) mp A % m=: #A th

Re: [Jprogramming] Hooked again

2017-02-13 Thread Louis de Forcrand
A few corrections: u is (|:C) mp A % m and v is (|:C) mp C % m but we can multiply both by m when showing that they are equal. In addition, I forgot a division by m here: > +/ (i{Et) * j {"1 E that should read +/ (i{Et) * j {"1 E % m. Louis > On 13 Feb 2017, at 01:35, Louis de

Re: [Jprogramming] Hooked again

2017-02-13 Thread Louis de Forcrand
our presentation, those two results should have been > the same. But they are not... > > Can you run through your work with some example values and see whether > you think it's the presentation or my understanding of it that needs > to change? > > Thanks, > > --

Re: [Jprogramming] Hooked again

2017-02-13 Thread Louis de Forcrand
mathematically equivalent. That is why my post may be hard to follow. Louis > On 13 Feb 2017, at 17:25, Raul Miller wrote: > > Eh... ok, but that's pretty hard to follow, and there's much simpler > ways of recognizing what's going on here. > > -- > Ra

Re: [Jprogramming] 2D animation

2017-02-13 Thread Louis de Forcrand
also works for 2d. > > > > On 9 Feb, 2017 12:42 am, "Louis de Forcrand" wrote: > > Hi everyone, > > I've been looking into the Qt facilities available in J recently, and I > read that 2D graphics are best done with gl2. > > I hacked together a

Re: [Jprogramming] Hooked again

2017-02-13 Thread Louis de Forcrand
of numbers would make it clearer. > t0=: ( (+/%#)@:*: - *:@:(+/%#) ) -: (+/%#)@:*:@:(- +/%#) > t1=: ( +/ @:*: - *:@:(+/)%# ) -:+/ @:*:@:(- +/%#) > check > t0?10#0 > t1?10#0 > >> On Feb 13, 2017, at 10:39 AM, Louis de Forcrand wrote: >> >> I'm

Re: [Jprogramming] Explicit fib

2017-02-26 Thread Louis de Forcrand
Perhaps use the recursive definition; slower but possibly easiest to understand (you can sneak in an M. if you don't talk about computation speed). fib=: 3 : 0 M. NB. 0-indexed if. y <: 1 do. y else. (fib y-1) + fib y-2 end. ) Louis > On 26 Feb 2017, at 20:37, Raul Miller wrote: > > Then

Re: [Jprogramming] Fast derivative of Softmax function

2017-02-27 Thread Louis de Forcrand
You probably know about it, but I'll mention it anyway: there's a primitive partial derivative operator in J. I think it would do exactly what you want (numerically), and it's probably reasonably fast. It's not too hard to use either: dsoftmax=: sm D.1 Louis > On 27 Feb 2017, at 10:20, 'Pasca

Re: [Jprogramming] type/domain of an argument

2017-04-03 Thread Louis de Forcrand
A few useful shortcuts: isBoxed=: 0 < L. isChar=: {.@, e. a."_ isInt=: = <. isReal=: = + Louis > On 2 Apr 2017, at 14:43, 'Pascal Jasmin' via Programming > wrote: > > datatype or 3!:0 > > > datatype 3 4.1 0 > > > > > > From: Herbert Weissenbaeck // Priva

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread Louis de Forcrand
Try this. On my phone, it runs almost 6 times faster than your version on your small example data, but uses more space (maybe sparse matrices would be faster?), with: 1e3 timespacex 'applycredits' 0.000630182 4608 vs 1e3 timespacex 'ac t' 0.000131279 6400 Of course this extra space cou

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread Louis de Forcrand
gt; Thanks Bo, Louis > > Louis - I will study your solution. J reports 'out of memory' on a million > rows. It is 6x faster than the larger data set too. Good solution! > >> On Thu, Apr 13, 2017 at 3:31 AM, Louis de Forcrand wrote: >> >> Try this. On my phone

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread Louis de Forcrand
Hi Bo, This is cool. As for the way you suggest using it here, isn't it equivalent to (without the first six rows of your data): (~.@[ ,. +//.)/@|: ? Louis > On 12 Apr 2017, at 21:57, 'Bo Jacoby' via Programming > wrote: > > Hi Joe! > My favorite datastructure is ORDINAL FRACTIONS - the alg

Re: [Jprogramming] Difference between jqt and JHS

2017-04-15 Thread Louis de Forcrand
Hi Linda, If you go to http://www.jsoftware.com/mailman/listinfo and choose your forum, you can then enter your email and subscription password in order to change subscription options. One of them is wether or not to recieve your own messages. Cheers, Louis > On 15 Apr 2017, at 21:38, Linda A

Re: [Jprogramming] J for iPad

2017-05-26 Thread Louis de Forcrand
Hi, Is this applicable to all devices running iOS? Thank you very much for the warning in any case. Louis > On 26 May 2017, at 11:43, Kip Murray wrote: > > My iPad Air now has iOS version 10.3.2 so I can no longer use J on my iPad. > --Kip Murray > > -- > Sent from Gmail Mobile > ---

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

2017-06-03 Thread Louis de Forcrand
How about 1 0 1 0 1 0 (#~ ((-: & 0 1 0)"1 @: ({~ & z)))~ z ? You can then "simplify": First the hook (and {~&z) ([ #~ -:&0 1 0"1@:(z&{)@])~ ([ #~ -:&0 1 0"1@:(z&{)@])~ Then ~ can be "distributed" over the resulting fork: [~ #~ -:&0 1 0"1@:(z&{)@(]~) ] #~ -:&0 1 0"1@:(z&{)@[ You can keep going

[Jprogramming] Complex residue

2017-06-22 Thread Louis de Forcrand
Hi, There's been recent discussion on the GNU APL forums about how to define the residue function on complex arguments. I wondered how it was specified in J, but the dictionnary page seems kind of vague. Nuvoc says that (x|y)=y-x*<.y%x+0=x for all scalars x and y (including complex numbers). H

Re: [Jprogramming] Complex residue

2017-06-23 Thread Louis de Forcrand
Thanks for the quick answers (and quick bug-fixing for that matter). Louis > On 23 Jun 2017, at 14:25, Henry Rich wrote: > > After reflection it seems clear that this is a bug in the implementation, so > I have fixed it for the next release, to match the Dictionary. > > Henry Rich > >> On 6/

Re: [Jprogramming] largest rectangle problem

2017-06-25 Thread Louis de Forcrand
Let V be a vector of real numbers, and V[i] its ith component. Then min( V[i] … V[j+1] ) = min( min( V[i] … V[j] ), min( V[i+1] … V[j+1] ) ). This version is based on that: ms=: #\ >./ . * [: >./@> # 2&(<./\&.>)&< ] 1e3 ts 'ms qq' 0.00491435 5.74234e6 Incorporating this in Mike's explicit

Re: [Jprogramming] largest rectangle problem

2017-06-25 Thread Louis de Forcrand
qq=: 1e4?.1e6 ts'cs1 qqq' 0.045429 398080 ts'cs qqq' 0.180366 397440 Real fast! Louis > On 25 Jun 2017, at 14:47, Louis de Forcrand wrote: > > Let V be a vector of real numbers, and V[i] its ith component. > Then > > min( V[i] … V[j+1] ) = min( min(

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-17 Thread Louis de Forcrand
A lot has been said on these forums about Jx and Unbox. They are unofficial J interpreters (with extensions to the language), are they not? Are they publicly available? I couldn't find anything about them on Google except older messages in the forum archives, but then again unfortunately this la

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-17 Thread Louis de Forcrand
We were >> planning to wait for the official J806 to become stable and resolve the Jx >> glitches but I might decide instead to release a current version, as is, >> soon. >> >> >> On Mon, Jul 17, 2017 at 7:40 AM, Louis de Forcrand wrote: >> >>>

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-19 Thread Louis de Forcrand
it (unorthodox) version >>https://rosettacode.org/wiki/First-class_functions#Tacit_. >> 28unorthodox.29_version >> [1] Tacit (unorthodox) version >> https://rosettacode.org/wiki/First-class_functions/Use_ >> numbers_analogously#Tacit_.28unorthodox.29_version >

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-19 Thread Louis de Forcrand
Sorry; I did digress from multiple assignment. Louis > On 19 Jul 2017, at 09:31, Raul Miller wrote: > > I believe that this discussion was about something different. > > Thanks, > > -- > Raul > >> On Wed, Jul 19, 2017 at 3:45 AM, Louis de Forcrand wrote

Re: [Jprogramming] Everyone giving dollars to random others

2017-07-19 Thread Louis de Forcrand
NB. tacit run=: upd rec upd=: [ ((({~ 0{::]) + 1{::])`(0{::])`[} - 2{::]) ~.@] ; ] (+//. ; ]) 1 <: [ NB. explicit RUN=: UPD rec UPD=: 4 : 0 b -~ x u}~ (x {~ u=. ~.y) + y +//. b=. x >: 1 ) rec=: ((] + ] >: i.@[) (?@$ <:))@# Slower on short vectors, faster on larger ones (j805): 1e2 ts 't

  1   2   >