Re: [Bug-apl] Strange behaviour of ,/

2014-02-03 Thread Jay Foad
On 31 January 2014 17:37, Elias Mårtenson wrote: > 8⎕CR ,/1 2 3 4 > ┌─┐ > │┌→──┐│ > ││1 2 3 4││ > │└───┘│ > └∊┘ I just have one comment to add to Kacper's excellent explanation: a useful thing to remember about this implementation of *reduction* is that it always *re

Re: [Bug-apl] Strange behaviour of ,/

2014-02-04 Thread Jay Foad
On 4 February 2014 04:17, Elias Mårtenson wrote: > Thank you. This made me aware of the fact that I still don't understand > this. You are right that the rank is zero, shown by the fact that ⍴,/1 2 3 > returns an empty result: > > 8⎕CR ⍴,/1 2 3 > ┌⊖┐ > │0│ > └─┘ > > > Can you explain to me w

Re: [Bug-apl] Can anything be done about the mailer's choice of encoding?

2014-02-04 Thread Jay Foad
The emails I get are full of beautifully rendered APL. Maybe it's a problem with your mail client? I'm reading them in Gmail. Jay. On 5 February 2014 05:44, David B. Lamkins wrote: > I'd really like to follow bug-apl via email, except that the mailer > doesn't seem to grok Unicode. All non-ASCII

Re: [Bug-apl] Short pause of program

2014-02-19 Thread Jay Foad
On 19 February 2014 14:05, Elias Mårtenson wrote: > I've reached the point where I have been able to reproduce the famous Dyalog > video where a guy builds a game of life and lets it animate by updating a > watched variable, with one exception: > > I need a way to sleep for a short while (less tha

Re: [Bug-apl] Dyadic / (replicate) does not work with ¨ (each)

2014-02-24 Thread Jay Foad
In IBM APL2, / ⌿ \ ⍀ are always operators: 3/4 ⍝ 3 is the left operand; derived function 3/ is applied monadically to the argument 4 4 4 4 1 1 0/¨'GNU' 'APL' ⍝ derived function 1 1 0/ applied to each of 'GNU' and 'APL' GN AP ... so you can't use /¨ in the way that you expected; in pr

Re: [Bug-apl] Non-bug: Help comparing solutions

2014-03-05 Thread Jay Foad
On 5 March 2014 05:25, Elias Mårtenson wrote: > Referencing yesterday's discussion about ⍤, I realised that I can use it to > get the indexes like this: > > X > ┌→─┐ > ↓xz│ > │zx│ > │ab│ > │ba│ > └──┘ > ⍋⍤1 X > ┌→──┐ > ↓1 2│ > │2 1│ > │1 2│ > │2 1│ > └───┘ > > > However, I can't figure

Re: [Bug-apl] Non-bug: Help comparing solutions

2014-03-05 Thread Jay Foad
> Out of curiosity, do you have a good solution without the use of a lambda? > "pure SO APL" if you like. I don't know how to do it in GNU APL. In Dyalog you can play silly games with ∘ (function composition) and ⍨, e.g.: ⎕ML←1 ⍝ ↑ is mix and ↓ is split ↑(⌷⍨∘(⊂∘⍋))⍨¨↓X ⍝ N.B. ⍵[⍋⍵] ←→

Re: [Bug-apl] Non-bug: Help comparing solutions

2014-03-06 Thread Jay Foad
>> Even the classic example of a fork (+/÷≡) is harder to read than its >> functional version {(+/⍵)÷≡⍵} and it goes downhill from there with longer >> trains. But maybe it's just me being unfamiliar with the syntax. > > > Did you intend to use ⍴ instead of ≡ there? I can't see how {(+/⍵)÷≡⍵} could

Re: [Bug-apl] Getting fractional timestamps

2014-03-07 Thread Jay Foad
On 7 March 2014 09:32, Elias Mårtenson wrote: > The ⎕TS function is useful for getting the current time and date, but is > there a function that can give me a simple timestamp as a single number > (milliseconds from some epoch). I'm mainly interested in using this when > benchmarking. For simple

Re: [Bug-apl] Dyalog power operator, what does it do?

2014-03-07 Thread Jay Foad
On 7 March 2014 09:15, Elias Mårtenson wrote: > Can you guys tell me if I understand what the power operator actually does? > The way I see it, it calls a function for a certain number of times, or > until the function returns the same thing as its input. There is on-line documentation for Dyalog

Re: [Bug-apl] Scan operator has strange behaviour

2014-03-21 Thread Jay Foad
On 21 March 2014 11:48, Elias Mårtenson wrote: > OK, I understand your explanation, and I have to say that the spec seems to > be a bit over-specified here. My (simplistic?) understanding of the > backslash operator was that it simply applied the given function on the > first two elements, add the

Re: [Bug-apl] Scan operator has strange behaviour

2014-03-21 Thread Jay Foad
On 21 March 2014 13:39, Elias Mårtenson wrote: > On 21 March 2014 19:55, Jay Foad wrote: >> Associativity matters because the last item of the result is 3>1>2, >> which means 3>(1>2). But your explanation would lead to (3>1)>2 as the >> last item. > &g

Re: [Bug-apl] EACH by axis

2014-03-31 Thread Jay Foad
On 31 March 2014 04:51, Elias Mårtenson wrote: > I keep wanting to be able to apply an axis argument to the ¨ (EACH) > operator. I.e, to sort an array rows, I wanted to do: > > {⍵[⍋⍵]}¨[2] foo > > > Instead, I had to do: > > ⊃ {⍵[⍋⍵]}¨ ⊂[2] foo > > > Would it make sense to be able to specify an ax

Re: [Bug-apl] How does a vector become a matrix?

2014-05-12 Thread Jay Foad
APL2's Disclose (Dyalog calls it Mix) will convert a vector of vectors into a matrix: ⊃'timor' 'mortis' ┌→─┐ ↓timor │ │mortis│ └──┘ Your second application of Disclose is applied to a 1-vector of 1-vectors (,⊂,7), so it returns a 1x1 matrix. Jay. On 12 May 2014 06:03, Blake McBrid

Re: [Bug-apl] How does a vector become a matrix?

2014-05-12 Thread Jay Foad
On 12 May 2014 15:43, Blake McBride wrote: > But if I enclose > and then disclose, I end up with something different - sometimes. That's not true. Disclose is a "left inverse" of Enclose: X ≡ ⊃⊂X ⍝ for all X Jay.

Re: [Bug-apl] How does a vector become a matrix?

2014-05-12 Thread Jay Foad
> ⍬≡⊃⊂⍬ > 0 That looks like a bug in GNU APL. It's true in IBM APL2 and Dyalog APL. Jay.

Re: [Bug-apl] box and unbox that work uniformly and without exceptions

2014-05-14 Thread Jay Foad
On 13 May 2014 15:00, Blake McBride wrote: > Here are the functions, examples to follow: > > ∇box[⎕]∇ > [0] z←box x > [1] z←⊂(⊂⍴x),⊂,x > > ∇unbox[⎕]∇ > [0] z←unbox x > [1] z←(⊃x[⎕IO])⍴⊃(x←⊃x)[⎕IO+1] FYI you can write your box as: z←⊂(⍴x)(,x) and unbox as: (s r)←⊃x ⋄ z←s⍴r Jay.

Re: [Bug-apl] box and unbox that work uniformly and without exceptions

2014-05-14 Thread Jay Foad
That's because of a bug in GNU APL: x←(1 2)(3 4) (a b)←x a≡1 2 0 :-( Jay. On 14 May 2014 15:24, Blake McBride wrote: > Your unbox doesn't work. The following does: > > (s r)←⊃x ⋄ z←(⊃s)⍴⊃r > > > On Wed, May 14, 2014 at 3:43 AM, Jay Foad wrote

Re: [Bug-apl] Revisiting the APL 2 empty-array display behavior

2014-05-29 Thread Jay Foad
On 29 May 2014 15:28, Juergen Sauermann wrote: > The method for discarding a value *Z *seems to be *0 0⍴**Z* instead > of *0⍴Z* these days. A smarter one could be monadic ⍪ ("table") > which turns an empty vector into an empty matrix (as does *0 0⍴*). > In Dyalog APL you can also use an empty d

Re: [Bug-apl] Question about behavior of ⍋

2014-07-09 Thread Jay Foad
Dyalog (same behaviour as NARS, I think): ⍋'AAA' 'Y' 'BBB' 'CC' DOMAIN ERROR Z←'AA' 'XX' 'AAA' 'XXX' ⍋⎕UCS¨Z DOMAIN ERROR ⎕ML←2 ⍋⊃Z 1 3 2 4 Jay. On 9 July 2014 03:59, Elias Mårtenson wrote: > I was looking specifically at the results of grade on a two-dimensional

Re: [Bug-apl] Extension proposal: ⍵⍵ to access outer lambda

2014-07-10 Thread Jay Foad
Note that this would conflict with the use of ⍺⍺ and ⍵⍵ in NARS2000 and Dyalog, where they refer to the operands of a defined operator. With three levels of nested lambdas would you also want to be able to use ⍵⍵⍵ in the innermost one, to refer to the value of ⍵ in the outermost one, and so on? J

Re: [Bug-apl] Changes to README-1-prerequisits

2014-07-15 Thread Jay Foad
The attached patch lets me build without libsqlite3-dev again, by moving both ResultValue.* and apl-sqlite.* into the "if SQLITE3" part of the makefile. Jay. On 15 July 2014 03:12, Elias Mårtenson wrote: > It's not supposed to. I think the error is that it still tries to compile > ResultValue.cc

Re: [Bug-apl] This looks wrong

2014-08-07 Thread Jay Foad
On 6 August 2014 14:15, Elias Mårtenson wrote: > My suggestion is that niladic lambda functions will not be allowed at all. > Instead, they will be interpreted as monadic functions that ignore their > argument. That's consistent with the behaviour of Dyalog. Jay.

Re: [Bug-apl] This looks wrong

2014-08-07 Thread Jay Foad
ow self-evaluation of niladic > lambdas. I.e. the expression {1} on its own does not evaluate to 1, but > rather to something else (it's displayed as {1}, and I'm not sure you can do > anything with it other than assigning it to a variable). > > Regards, > Elias > > &g

Re: [Bug-apl] This looks wrong

2014-08-07 Thread Jay Foad
> So the only benefit of the GNU APL approach is that it > allows the definition of niladic functions by assigning from a lambda. I don't understand. You can't use assignment to name a niladic lambda in GNU APL, because it will be evaluated before the assignment happens: f←{1⊣⎕←2} 2 f

Re: [Bug-apl] This looks wrong

2014-08-07 Thread Jay Foad
the number 2 printed to the session: f 1 Thanks, Jay. On 7 August 2014 11:44, Juergen Sauermann wrote: > The reason why ⎕NC shows 2 below is because 'f' is a variable whose current > value is a function. > > /// Jürgen > > > > > On 08/07/2014 10:52 AM,

Re: [Bug-apl] This looks wrong

2014-08-07 Thread Jay Foad
Right. Even in GNU APL monadic lambdas consume and ignore any left argument you give them, so you could argue that it's consistent for niladic lambdas to consume and ignore both arguments. Jay. On 7 August 2014 14:53, Elias Mårtenson wrote: > And, one could argue that knowing that lambdas are al

Re: [Bug-apl] Bug in the parser?

2014-11-25 Thread Jay Foad
On 25 November 2014 at 13:38, Juergen Sauermann wrote: > I have read the IBM binding rules a number of times but they seem not to > help. The problem of these rules is > that they give different results in the cases where / is an operator and > where / is a function. In IBM APL2 / is always an op

Re: [Bug-apl] Bug in the parser?

2014-11-25 Thread Jay Foad
On 25 November 2014 at 14:06, Jay Foad wrote: > On 25 November 2014 at 13:38, Juergen Sauermann > wrote: >> I have read the IBM binding rules a number of times but they seem not to >> help. The problem of these rules is >> that they give different results in the cases wh

Re: [Bug-apl] Bug in the parser?

2014-11-27 Thread Jay Foad
Hi Jürgen, Thanks for doing the analysis. > 2. Alternatives > - > > I have tested what happens if we would introduce a M M pattern into GNU APL > in order to > get IBM APL2's behavior. I don't understand this bit. Monadic operators don't bind like this in APL2. Surely the w

Re: [Bug-apl] Ctrl-D and )off

2014-12-19 Thread Jay Foad
(Resending because I forgot to cc the list.) I agree that this is annoying, especially for new and casual users. The only good reason I can think of for APL not exiting on Ctrl-D is that if you accidentally hit Ctrl-D, you could accidentally lose the whole contents of your workspace. At least in

Re: [Bug-apl] axis specification issue... (?)

2015-04-14 Thread Jay Foad
On 14 April 2015 at 07:31, Fausto Saporito wrote: > Hello, > > as I wrote before I'm trying to use the Sullivan multi precision > package with GNU APL. > That workspace was written with Dyalog APL in mind, so there're some > Dyalog feature we saw before ([]SIGNAL, []FMT). > Those are now ok. > > B

Re: [Bug-apl] defining new operator

2015-04-14 Thread Jay Foad
You shouldn't need a space after the right parenthesis. This works for me: z←(F scan)x;y z←⊂y←↑x ∆1:→(0=⍴x←1↓x)/0 z←z,⊂y←y F↑x →∆1 +scan 2 3 4 2 5 9 I had to: - change " to ↓ for Drop - use monadic ↑ instead of ⊃ for First (this is a Dyalog "migration level" thing) - replace modified assi

Re: [Bug-apl] SVN 624 Warnings

2015-05-07 Thread Jay Foad
Hi Jürgen, It's warning about line 51: rw_sv_def(CHI, "{ ... } axis argument") In this case you get "CHI" + 5, which is indexing way off the end of the string, which is why it's warning. Jay. On 7 May 2015 at 11:27, Juergen Sauermann wrote: > Hi, > > I believe by string they mean a simpl

[Bug-apl] Fwd: tensor product

2015-05-20 Thread Jay Foad
(Forgot to cc the list.) -- Forwarded message -- From: Jay Foad Date: 20 May 2015 at 14:55 Subject: Re: [Bug-apl] tensor product To: Fausto Saporito "Why" does it give a multidimensional result? Because that's the way it's defined in APL. APL has generalise

Re: [Bug-apl] line label branching style

2015-07-14 Thread Jay Foad
I don't think there's much difference. Both are (were) reasonably common. The first one has the condition on the left, so you usually have to parenthesise it. The second one only works when ⎕IO=1. Jay. On 14 July 2015 at 03:19, wrote: > I found some very old code that uses two different styles

Re: [Bug-apl] What do Quad-slash and Quad-Backslash do?

2015-07-20 Thread Jay Foad
What's the paper? Does it say which APL they were using? On 19 July 2015 at 16:25, wrote: > Hi Bug APL, > > I found a paper that computes eigenvalues using the following equation > eig←{t[;⍒(t←⍂⍵)[0;]]} > > where ⍵ is a matrix of coefficients. > > It looks like the symbols are in the unicode sta

Re: [Bug-apl] Fuzzy Floor and Ceiling

2015-08-12 Thread Jay Foad
I don't know anything about the GNU APL implementation, but I can tell you that the definition of tolerant-floor changed between standard APL (ISO 8485) and Extended APL (ISO 13751). In ISO 8485 the tolerance is relative, so both your examples should definitely return 5. In Extended APL the toleran

Re: [Bug-apl] Localizing ⎕CT

2015-08-21 Thread Jay Foad
FYI Dyalog works the same way. It's called "pass-through localisation" of system variables. Jay. On 20 August 2015 at 15:20, Mike Duvos wrote: > The behavior seems to be that localized ⎕ variables inherit the value they > had in the outer context unless you change them. If you do change them,

Re: [Bug-apl] Localizing ⎕CT

2015-08-21 Thread Jay Foad
FYI this is different from NARS2000 and Dyalog, which leave ⎕-variables set to their current value, rather than setting them to some default value. Jay. On 21 August 2015 at 11:04, Juergen Sauermann wrote: > this is a GNU APL feature. Instead of leaving ⎕-variables undefined > and raising the ac

[Bug-apl] problems with ^D

2015-08-21 Thread Jay Foad
When I build and run GNU APL on Ubuntu 15.04, ^D seems to behave strangely. 1. The first four times I hit it I get "^D" echoed, followed by a blank line and a helpful message. After that I just get "^D" echoed, with no message at all. (I expected it to exit the interpreter if I hit it n times in a

Re: [Bug-apl] A better way to insert characters into a character vector?

2015-08-28 Thread Jay Foad
You can use ∊ (Enlist) instead of ⊃,/. Here's another way from "the good old days, before all this nested array malarkey" (from Morten Kromberg): a←'alex' rep←1+2×m←a='e' r←rep/a ⋄ m←rep/m (m/r)←'www' r alwwwx Jay. On 28 August 2015 at 03:17, wrote: > Hi Bug APL,

Re: [Bug-apl] Performance problem with simple program

2015-10-06 Thread Jay Foad
Your solution is inherently O(n²) because you're using ¨⍳ inside ¨⍳. The obvious way to fix this is with +\: (⍳N)⍪[1.5]+\{+/⍎¨⍕⍵}¨⍳N←400 The other obvious source of inefficiency is your use of ⍕ and ⍎. Instead, how about: (⍳N)⍪[1.5]+\+⌿10 10 10⊤⍳N←400 I don't know how to do timings in GNU APL s

Re: [Bug-apl] Performance problem with simple program

2015-10-06 Thread Jay Foad
It's slightly annoying that you have to know how many 10s to use on the left of ⊤. You can work it out as: ((1+⌊10⍟N)⍴10)⊤... On 6 October 2015 at 09:44, Jay Foad wrote: > (⍳N)⍪[1.5]+\+⌿10 10 10⊤⍳N←400

Re: [Bug-apl] Performance problem with simple program

2015-10-07 Thread Jay Foad
On 7 October 2015 at 15:19, Peter Teeson wrote: > I was wondering why the APL Lang Ref Manual p.161 shows: > ⌊1+L⍟(|R)+R=0 > > Why would this not be just as correct? > ⌈L⍟(|R)+R=0 > > and so >> ((⌈10⍟N)⍴10)⊤... This would tell you that 1000 only has 3 digits. Jay.

Re: [Bug-apl] 100?100 hang-up

2015-10-13 Thread Jay Foad
But 104?104 is fine! It's broken when the argument is not a multiple of 8. This code (in Bif_F12_ROLL::eval_AB in ScalarFunction.cc) should round up to a multiple of 8, not down. // set_size can be rather big, so we new/delete it // uint8_t * used = new uint8_t[set_size/8]; memset(used, 0

Re: [Bug-apl] Fwd: tensor product

2016-01-25 Thread Jay Foad
How about: tensor←{((⍴⍺)×⍴⍵)⍴(⍋⍋0 1⍴⍨(⍴⍴⍺)+⍴⍴⍵)⍉⍺∘.×⍵} I think this is a more elegant generalisation than using ⍣. It should also work in 3 or more dimensions. The left argument of the dyadic transpose needs to be 1 2 (for vectors), 1 3 2 4 (for matrices), 1 4 2 5 3 6 (for cubes) etc. This is an

Re: [Bug-apl] value error when using 'Cut'

2016-02-08 Thread Jay Foad
FYI Dyalog are considering introducing Cut into a future version of Dyalog APL and would welcome feedback or collaboration on the design: http://video.dyalog.com/Dyalog15/?v=9KOto3xXS3c http://www.dyalog.com/uploads/conference/dyalog15/presentations/D16_Future_Operator_Proposals.zip http://www.dya

Re: [Bug-apl] IOTA

2016-03-02 Thread Jay Foad
Cool! For bonus marks can you make it work in the degenerate case: ⍳⍬ ←→ ⊂⍬ ? Jay. On 2 March 2016 at 02:23, Elias Mårtenson wrote: > Looking at it further, I realise you need do disclose the result in order to > make them equivalent: > > IOTA ← {⊃∘.,/⍳¨⍵} > > Regards, > Elias > > On 2

Re: [Bug-apl] IOTA

2016-03-03 Thread Jay Foad
Right. Here's a variation on Elias's solution that gets IOTA ⍬ right, but doesn't handle the singleton cases correctly! IOTA ← {⊃∘.,/(⍳¨⍵),⊂⊂⍬} On 3 March 2016 at 01:08, Nick Lobachevsky wrote: > There is at least one other degenerate case, namely the "legacy" > singleton, or one element vector.

Re: [Bug-apl] IOTA

2016-03-03 Thread Jay Foad
On 3 March 2016 at 08:12, Elias Mårtenson wrote: > What is the purpose of the double-enclose ⊂⊂⍬ ? > > My understanding was that (⊂⊂x)≡⊂x for all x? No! ⊂ is a no-op on simple scalars like 42, but not on enclosures like ⊂⍬. You can enclose most arrays (i.e. anything except simple scalars) as many

Re: [Bug-apl] IOTA

2016-03-03 Thread Jay Foad
On 3 March 2016 at 11:40, Juergen Sauermann wrote: > Therefore I believe Elias' statement > > My understanding was that (⊂⊂x)≡⊂x for all x? > > is correct as far as ISO, IBM APL2, and GNU APL are concerned. It is clearly not true in APL2! x←1 2 3 (⊂⊂x)≡⊂x 0 (Same result in NARS2000

Re: [Bug-apl] Feature suggestion: multiple function arguments

2016-03-07 Thread Jay Foad
FYI Dyalog version 14 has forks. You can try it at tryapl.org: http://tryapl.org/?a=%28+%u233F%F7%u2262%291%202%203%204&run Jay. On 5 March 2016 at 17:17, Louis de Forcrand wrote: > To add to the confusion, while > ( {+⌿ ÷ ≢} y) ≡ ( +⌿y) ÷ ≢y > (x {+⌿ ÷ ≢} y) ≡ (x+⌿y) ÷ x≢y > whatever that doe

Re: [Bug-apl] indexing of the array

2016-03-07 Thread Jay Foad
Right. This is one of the few cases where APL2 broke compatibility with first-generation APL, where 7 8 9[2] was 8. Personally I think the APL2 way is better, because A[B] C[D] parses as (A[B])(C[D]). This makes much more sense to me than the Dyalog parsing, which is ((A[B]) C)[D]. Jay. On 5 Mar

Re: [Bug-apl] Feature suggestion: multiple function arguments

2016-03-15 Thread Jay Foad
In APL2 this is not a problem, because / et al are always operators: 1 2 /¨ 3 4 ⍝ in APL2 this parses as (1 2 /)¨ 3 4 3 3 3 4 4 4 1 2 /¨ 3 4 ⍝ in GNU APL this parses as 1 2 (/¨) 3 4 3 4 4 Jay. On 14 March 2016 at 13:03, Juergen Sauermann wrote: > Hi Kacper, > > yes. The tricky

Re: [Bug-apl] Feature suggestion: multiple function arguments

2016-03-15 Thread Jay Foad
On 15 March 2016 at 13:24, Elias Mårtenson wrote: > On 15 March 2016 at 21:14, Jay Foad wrote: >> >> 1 2 /¨ 3 4 ⍝ in APL2 this parses as (1 2 /)¨ 3 4 >> 3 3 3 4 4 4 > > Are you saying that (1 2 /)¨ 3 4 is syntactically correct in APL2? Yes. / is an ope

Re: [Bug-apl] Substring replacement in APL

2016-04-12 Thread Jay Foad
replace←{(⍴v)↓∊(⊂v),¨(↑⍴u)↓¨(+\u⍷a)⊂a←u,⍺⊣(u v)←⍵} Jay. On 12 April 2016 at 11:39, Elias Mårtenson wrote: > I had a need to to replace substrings with a replacement, and I'm having a > hard time coming up with an concise solution. What I need to do is this: > > 'foobartestfootest' replace

Re: [Bug-apl] fractional power ¯8⋆÷3

2016-04-13 Thread Jay Foad
I'd guess -ffinite-math-only. Jay. On 13 April 2016 at 19:36, Xiao-Yong Jin wrote: > Looks like a gcc optimization problem (clang works correctly). > Using ‘-Ofast’ with gcc 5.3 reproduces the bug. > Using ‘-O3’ works fine. > > So one of the options down here caused the bug: > -fassociative-math

Re: [Bug-apl] Unexpected result when attempting to enclose over rows

2016-04-26 Thread Jay Foad
I agree that this seems like a bug. Your example works in NARS2000 and Dyalog. To make it work in GNU APL I currently have to do an extra enclose: ({⊂⊂⍵}⍤1)z,⍪z←⍳4 ┌→──┐ │┌→──┐ ┌→──┐ ┌→──┐ ┌→──┐│ ││1 1│ │2 2│ │3 3│ │4 4││ │└───┘ └───┘ └───┘ └───┘│ └∊──

Re: [Bug-apl] Supporting negative ranks for ⍤ operator

2016-04-27 Thread Jay Foad
You're reading section 9.3.4 "Rank operator deriving monadic function". You also need to look at 9.3.5 "Rank operator deriving dyadic function". Given g ← f⍤P Q R: P is the monadic rank Q is the left rank R is the right rank So: g Y applies g to the P-cells of Y X g Y applies g to the Q-cells of

Re: [Bug-apl] Supporting negative ranks for ⍤ operator

2016-04-27 Thread Jay Foad
Incidentally, it works like this in Dyalog and NARS2000 too, though the Dyalog documentation doesn't mention the 3-item form. Jay. On 27 April 2016 at 09:02, Jay Foad wrote: > Given g ← f⍤P Q R: > P is the monadic rank > Q is the left rank > R is the right rank > > So: &

Re: [Bug-apl] Supporting negative ranks for ⍤ operator

2016-05-06 Thread Jay Foad
On 6 May 2016 at 13:52, Juergen Sauermann wrote: > Except maybe for the Dyalog ¯1 case (primarily because I don't know what > "major cells" are). Dyalog treats ¯1 the same as the ISO standard (and therefore also GNU APL). "Major cell" is explained on page 14 of: http://docs.dyalog.com/14.1/Dyalog

Re: [Bug-apl] jot dot jot dot?

2016-06-27 Thread Jay Foad
So it looks like GNU APL parses ∘.∘.+ as ∘.(∘.+). IBM APL2 and Dyalog appear to parse it as (∘.∘).+. Jay. On 15 June 2016 at 04:05, Xiao-Yong Jin wrote: > Hi Alex, > > It is correct. You need nested vectors to see the effect. > > Try the following. > > (⊂[2]2 3⍴⍳6)∘.{⍺∘.{⍺+⍵⊣⎕←⍺,'I',⍵}⍵

Re: [Bug-apl] jot dot jot dot?

2016-06-28 Thread Jay Foad
ived > function) because all arguments > of . are available before the . and ∘ on the left show up. > > What is missing in both the ISO standard and in the APL2 language > reference is a > statement about left-to-right or right-to-left associativity of APL > operators. I persona

Re: [Bug-apl] Not a bug, need help coding search&replace on a vector

2016-06-28 Thread Jay Foad
On 23 June 2016 at 15:28, Xiao-Yong Jin wrote: > > > On Jun 23, 2016, at 7:07 AM, Louis Chretien wrote: > > > > R←{X} (A ⎕R B) Y > > The line on the title? It’s not really the language syntax. It’s their > way to tell you that ⎕R is an operator that receives required left and > right operands

Re: [Bug-apl] jot dot jot dot?

2016-06-28 Thread Jay Foad
I don't think that's true. Here's an example from IBM APL2 Workstation: (1 2)(3 4)∘.∘.*(5 6)(7 8) SYNTAX ERROR (1 2)(3 4)∘.∘.*(5 6)(7 8) ^ (1 2)(3 4)(∘.∘).*(5 6)(7 8) SYNTAX ERROR (1 2)(3 4)(∘.∘).*(5 6)(7 8) ^ (1 2)(3 4)∘.(∘.*)(5 6)(7 8) 1 1 1

Re: [Bug-apl] jot dot jot dot?

2016-06-29 Thread Jay Foad
gt; > >>> +.×/ ←→ (+.× )/ not + .(× /) > >>> " > >>> > >>> However, the binding strength resolves the ambiguity in the IBM > example only > >>> because / is not a dyadic operator. In Alex's example the operator is > dyadi

Re: [Bug-apl] jot dot jot dot?

2016-06-29 Thread Jay Foad
Can you explain what cases you have fixed? All the cases I showed seemed to working correctly already in GNU APL. Thanks, Jay. On 28 June 2016 at 19:09, Juergen Sauermann wrote: > Hi, > > thanks, fixed in *SVN 620*. > > /// Jürgen > > > On 06/28/2016 01:23 PM, Jay

Re: [Bug-apl] multiple inner product

2016-07-07 Thread Jay Foad
On 7 July 2016 at 03:59, Kacper Gutowski wrote: > The standard explicitly says A f.g B ←→ f/A g B when A & B vectors. > (I think you meant ⊂f/A g B on the RHS?) But in the +.(+.+) case, it's Dyalog that gives unexpected results: > > +/A(+.+)B > 33 66 66 66 > A+.(+.+)B > 99 132

Re: [Bug-apl] multiple inner product

2016-07-07 Thread Jay Foad
On 7 July 2016 at 11:39, Kacper Gutowski wrote: > On 7 July 2016 at 11:07, Jay Foad wrote: > > (I think you meant ⊂f/A g B on the RHS?) > > No, I don't think I did. That enclosure is already a result of reduction. > I was thinking of cases like this (in GNU APL):

Re: [Bug-apl] multiple inner product

2016-07-07 Thread Jay Foad
There was some relevant discussion in comp.lang.apl here: https://groups.google.com/forum/#!topic/comp.lang.apl/23LrwRZKmPs On 6 July 2016 at 19:31, Xiao-Yong Jin wrote: > The following from GNU APL, > > (⊂[1]⍳2 3)+.+.+⊂[1]10×⍳2 3 > 209 198 > (⊂[1]⍳2 3)(+.+).+⊂[1]10×⍳2 3 > 209 198

Re: [Bug-apl] multiple inner product

2016-07-08 Thread Jay Foad
On 7 July 2016 at 12:57, Kacper Gutowski wrote: > On 7 July 2016 at 12:55, Jay Foad wrote: > > (⊂+/3 4 ⍴ 5 6)≡3 4 +.⍴ 5 6 > > 1 > > Ah, I see what you mean. But it still wasn't my error, it's really what > ISO says. It's not equivalent to APL2 de

[Bug-apl] dfn-reduction bug

2016-07-08 Thread Jay Foad
Juergen, Just in case you missed this, buried in another thread: X←⊂¨,¨⍳2 ⋄ (+/X) ≡ ({⍺+⍵}/X) 0 FYI I get the following results on various APLs: X←⊂¨,¨⍳2 ⋄ (≡+/X)(≡{⍺+⍵}/X) ⍝ GNU APL 2 3 X←⊂¨,¨⍳2 ⋄ (≡+/X)(≡{⍺+⍵}/X) ⍝ Dyalog APL 3 3 X←⊂¨,¨⍳2 ⋄ (≡+/X)(≡{⍺+⍵}/X) ⍝ NARS 2000

Re: [Bug-apl] multiple inner product

2016-07-08 Thread Jay Foad
On 8 July 2016 at 09:04, Kacper Gutowski wrote: > But I was looking at the evaluation sequence just below the informal > description you quoted and after some reshaping and scalar expansion > it says: > > > If A1 and B1 are both vectors, return f/A1 g B1. > > Otherwise, set Z to an array such tha

Re: [Bug-apl] 0⍟0

2016-07-13 Thread Jay Foad
My ISO ("First edition 2001-02-01") says: Evaluation Sequence: If either of A or B are not numbers signal domain-error. If A and B are equal, return one. If A is one, signal domain-error. Set A1 to the natural-logarithm of A. Set B1 to the natural-logarithm of B. Return B1 divided-by A

Re: [Bug-apl] 0⍟0

2016-07-13 Thread Jay Foad
ense to me but the standard does not mention *⎕IO* for *⍟*. > > /// Jürgen > > > On 07/13/2016 01:05 PM, Jay Foad wrote: > > My ISO ("First edition 2001-02-01") says: > > Evaluation Sequence: > If either of A or B are not numbers signal domain-error. >

Re: [Bug-apl] 0⍟0

2016-07-14 Thread Jay Foad
In practice I think the "if A and B are equal" case is only there to handle 0⍟0. For all other cases of A=B the result of 1 falls out naturally from the general definition (as long as you support complex numbers). And for testing 0=0, ⎕CT is irrelevant; comparisons with zero are never tolerant. And

Re: [Bug-apl] A couple of bugs, and a question on the power operator

2016-08-15 Thread Jay Foad
On 13 August 2016 at 13:05, Juergen Sauermann wrote: > In "Mastering Dyalog APL" I haven't found the monadic case for the right > function argument > G of the power operator. In that book G seems to be always dyadic. So the > monadic case looks > like a new Dyalog invention. And, if it is defined

Re: [Bug-apl] A couple of bugs, and a question on the power operator

2016-08-15 Thread Jay Foad
> > thanks, I see. If I read your examples correctly then Dyalog has a special > syntax {A} to mark the left argument A > of a defined function as optional and, as a consequence, to declare a > function as ambivalent. > Right. In Dyalog tradfns can be monadic, dyadic or ambivalent; dfns are always

Re: [Bug-apl] A couple of bugs, and a question on the power operator

2016-08-15 Thread Jay Foad
tement is correct or not, but if it is then I > would prefer to not > introduce this "monadic case" in GNU APL for the reasons explained earlier. > > Thanks, > Jürgen > > > On 08/15/2016 10:16 AM, Jay Foad wrote: > > On 13 August 2016 at 13:05, Juergen Sauer

Re: [Bug-apl] A couple of bugs, and a question on the power operator

2016-08-16 Thread Jay Foad
On 16 August 2016 at 02:53, Louis de Forcrand wrote: > If I understand correctly then, in F {pow} G, G's left argument is > _always_ the result of the power operator if G is true. Its right argument > then is _always_ the result of the previous iteration. Is that correct? > Yes, G is always used

Re: [Bug-apl] Spell corrector - APL

2016-09-12 Thread Jay Foad
Hi Ala'a, How about replacing the last line with this? It runs in about 1 minute on my machine: desc 39 2⍴(⍪u),≢¨⊂⍨x[⍋x←u⍳w] Jay. On 11 September 2016 at 19:23, Ala'a Mohammad wrote: > Just an update as a reference, I'm now able to parse the big.txt file > (without WS full or killed process),

Re: [Bug-apl] Spell corrector - APL

2016-09-13 Thread Jay Foad
hanks for the alternative, I'd tried to run it, but got Rank Error > > RANK ERROR > λ1[1] λ←⍵[⍒⍵[;2];] > ^^ > > How can I help debug this? > > Regards, > > Ala'a > > On Mon, Sep 12, 2016 at 5:32 PM, Jay Foad wrote: > > Hi Ala'a,

[Bug-apl] Incomplete value at Symbol.cc:132

2016-09-26 Thread Jay Foad
r←6371 hf←{2×rׯ1○(+/(2*⍨1○(p-q)÷2)×1(×/2○⊃¨p q))*÷2⊣(p q)←○⍺ ⍵÷180} 36.12 ¯86.67 hf 33.94 ¯118.40 Incomplete value at Symbol.cc:132 Addr:0x2645b00 Rank:1 Shape: ⊏2⊐ Flags: -- First: 0.6304129258 Dynamic: DynamicObject: 0x2645b08 (Value: 0x2645b00) : prev: 0

Re: [Bug-apl] Assertion failed in 'equal'

2016-10-18 Thread Jay Foad
This is called "ranking" and is very simple in APL: ⍋⍋'GNUAPL' 2 4 6 1 5 3 The permutations 4 1 6 2 5 3 (i.e. ⍋'GNUAPL') and 2 4 6 1 5 3 are inverses of each other, and ⍋ will invert a permutation. Jay. On 17 October 2016 at 15:41, Ala'a Mohammad wrote: > Hi Juergen, > > Thanks for the

Re: [Bug-apl] hexcodes to unicode points

2016-10-28 Thread Jay Foad
The rows of 13 4 ⍴ idx show the individual bytes of the UTF-8 encoding of some characters. Convert to text with e.g.: 19 ⎕CR ⎕UCS 226 141 186 226 141 181 ⍺⍵ To convert the other way: ⎕UCS 18 ⎕CR cards 240 159 130 168 240 159 130 166 ... Jay. On 28 October 2016 at 06:10, wrote: >

Re: [Bug-apl] Squad

2016-11-01 Thread Jay Foad
FYI this was introduced as a compatible extension in Dyalog APL 13.0, along with a similar extension to Take and Drop: MAT 11 12 13 14 21 22 23 24 31 32 33 34 2↑MAT 11 12 13 14 21 22 23 24 1↓MAT 21 22 23 24 31 32 33 34 Jay. On 31 October 2016 at 23:34, Christian Robert wrote:

Re: [Bug-apl] Quad-DLX implementation of Sudoku soon

2016-12-02 Thread Jay Foad
Your boxed display seems to be missing the 3 in the bottom left corner of a. Jay. On 2 December 2016 at 03:10, Christian Robert wrote: > Not a bug report, > > > Left arg of GenGRID is maximum number of seconds to run (arg is optional > and default to 30 secs) > Right arg of GenGRID is the targe

Re: [Bug-apl] Best way to solve my daughter's maths problem

2017-01-25 Thread Jay Foad
How about this, based on enumerating binary trees: e←{⍵,⊂f ⍵} f←{↑,/(⊂⍵)g¨⍳≢⍵} g←{↑,/,(⍵⊃⍺)∘.h ⍵⊃⌽⍺} h←{(⊂'(',⍺),¨'+-×÷',¨⊂(⍵,')')} t1←,⊂,'4' ⍝ vec of charvecs representing trees of size 1 t←,⊂t1 ⋄ t←e⍣4⊢t (t1 t2 t3 t4 t5)←t Now t5 is a list of parenthesi

Re: [Bug-apl] Best way to solve my daughter's maths problem

2017-01-26 Thread Jay Foad
Simpler f and g: e←{⍵,⊂f ⍵} f←{↑,/⍵ g¨⌽⍵} g←{↑,/,⍺∘.h ⍵} h←{(⊂'(',⍺),¨'+-×÷',¨⊂(⍵,')')} Jay. On 25 January 2017 at 10:59, Jay Foad wrote: > How about this, based on enumerating binary trees: > > e←{⍵,⊂f ⍵} > f←{↑,/(⊂⍵)g¨⍳≢

Re: [Bug-apl] ⎕FIO[49]

2017-01-27 Thread Jay Foad
Just FYI, it's similar to Dyalog's ⎕NGET . (I'm not suggesting NGET is necessarily a good name to use in wslib5.) On 27 January 2017 at 02:03, Elias Mårtenson wrote: > Speaking of which, ⎕FIO[49] needs a name in wslib5. Any

Re: [Bug-apl] indexing precedence

2017-02-16 Thread Jay Foad
This was a breaking change in APL2 (previously 1 2 3[2] was valid and returned 2) but I think it was the right decision for a language with stranding. It means that A[1] B[2] parses as (A[1])(B[2]) which seems sane. The alternative (ISO, Dyalog) is that A[1] B[2] parses as (A[1] B)[2], which is pr

Re: [Bug-apl] [PATCH]: allow using lambdas in ]USERCMD

2017-02-24 Thread Jay Foad
⎕AI gives you a way to measure elapsed time and CPU time. On 24 February 2017 at 07:29, Elias Mårtenson wrote: > I agree with you that extensions should, as far as possible, be in a > loadable package. > > However, some features can't be built in pure APL. Either because the > underlying functio

Re: [Bug-apl] West way to remove substrings?

2017-03-14 Thread Jay Foad
This is a bit simpler and fixes the empty result problem, and returns a non-enclosed result: RemoveSubstrings ← {⍵/⍨ ~⊃∨/ (-⍳⍴⍺) ∘.⌽ ⊂⍺⍷⍵} Like your solution this only works with ⎕IO←0. On 14 March 2017 at 14:20, Elias Mårtenson wrote: > In a discussion on the #lisp IRC channel recently, someo

Re: [Bug-apl] Is the index generator function definition allowed to work on vectors of any length?

2017-04-11 Thread Jay Foad
It's in Dyalog and NARS2000 documentation: http://help.dyalog.com/15.0/Content/Language/Primitive%20Functions/Index%20Generator.htm http://wiki.nars2000.org/index.php/Index_Generator On 11 April 2017 at 02:55, Leslie S Satenstein wrote: > Re Gnu APL. 1,7-1 > > Gnu apl processes ⍳ 25 > a

Re: [Bug-apl] Problem with modulo arithmetic on Gaussian integers

2017-04-26 Thread Jay Foad
I see the wrong result on my machine, just like Fred. Jürgen, the problem seems to be in this code: // if ⎕CT != 0 and B ÷ A is close to an integer within ⎕CT then return 0. // // Note: In that case, the integer to which A ÷ B is close is either // floor(A ÷ B) or ceil(A ÷ B). // co

Re: [Bug-apl] Problem with modulo arithmetic on Gaussian integers redux

2017-06-14 Thread Jay Foad
It got broken in r939. The problem is in Cell.icc: //- inline bool Cell::integral_within(APL_Complex A, APL_Float B) { const APL_Complex C = -A; return tolerant_floor(C, B) == tolerant_floor(A, B); } //-

Re: [Bug-apl] Problem with modulo arithmetic on Gaussian integers redux

2017-06-15 Thread Jay Foad
On Wed, 2017-06-14 at 17:20 +0200, Juergen Sauermann wrote: > > Hi Jay, Fred, > > thanks a lot, Jay, for figuring this out. > > Fred, I made the change proposed by Jay. Please let me know if the > problem persists. *SVN

Re: [Bug-apl] Problem with modulo arithmetic on Gaussian integers redux

2017-06-15 Thread Jay Foad
a | b* > *computing (-12,10) modulo (-1,11)* > *⎕CT is: 1e-13* > *the quotient B ÷ A is: (1,1)* > *result is 0 because the quotient is integral within ⎕CT* > *0* > > Just replace your *ComplexCell.cc* with the attached one. > > Thanks, > Jürgen > > > On 06

Re: [Bug-apl] Problem with modulo arithmetic on Gaussian integers redux

2017-06-15 Thread Jay Foad
Sorry, please ignore that. I had not done an svn update. With the latest svn I get: ¯1J11 | ¯12J10 0 ... so it's looking good! On 15 June 2017 at 13:50, Jay Foad wrote: > I get: > > ¯1J11 | ¯12J10 > computing (-12,10) modulo (-1,11) > ⎕CT is: 1e-13 >

  1   2   >