Re: [Jprogramming] wait, what?

2014-09-12 Thread 'Pascal Jasmin' via Programming
works in J7 too (152{a.)~ 0 1 2 3 4 5 6 7 8 - Original Message - From: Raul Miller To: Programming forum Cc: Sent: Friday, September 12, 2014 10:09 PM Subject: Re: [Jprogramming] wait, what? I was using jqt 802 on desktop. FYI, -- Raul On Fri, Sep 12, 2014 at 9:09 PM, bill la

Re: [Jprogramming] Using a data arrays to send images

2014-09-12 Thread Linda Alvord
I got it to work! In under 5 minutes it creates R with 300 items that is then decoded into S and reproduces the original image. It's chances of doing that by chance is about 1 in 1.5 trillion. load 'viewmat' GRB256=:1 0 2({"1) 256 256 256#:i.256^3 Q=:?(300 300)$ 16777216x R=:16777216 #. Q S=:(

Re: [Jprogramming] wait, what?

2014-09-12 Thread bill lam
Thanks for the report. It seems android got a bug that it should raise error for indirect assignment to an illegal utf8 name. (152{a.) On Sep 13, 2014 10:27 AM, "Raul Miller" wrote: > I get an ill-formed name error. > > Thanks, > > -- > Raul > > On Fri, Sep 12, 2014 at 10:25 PM, bill lam wrote:

Re: [Jprogramming] wait, what?

2014-09-12 Thread Raul Miller
Looking for other examples: (128}.i.65536)#~_2 wrote: > May be you can try this, >u:955 > λ >(a=.utf8 u:955)=. i.2 3 >a > λ >a~ > 0 1 2 > 3 4 5 >λ > 0 1 2 > 3 4 5 >λ * 2 > 0 2 4 > 6 8 10 > > I cannot type lambda, the lambda was copied from the output in j session. > Tes

Re: [Jprogramming] wait, what?

2014-09-12 Thread Raul Miller
I get an ill-formed name error. Thanks, -- Raul On Fri, Sep 12, 2014 at 10:25 PM, bill lam wrote: > May be you can try this, >u:955 > λ >(a=.utf8 u:955)=. i.2 3 >a > λ >a~ > 0 1 2 > 3 4 5 >λ > 0 1 2 > 3 4 5 >λ * 2 > 0 2 4 > 6 8 10 > > I cannot type lambda, the lambda w

Re: [Jprogramming] wait, what?

2014-09-12 Thread bill lam
May be you can try this, u:955 λ (a=.utf8 u:955)=. i.2 3 a λ a~ 0 1 2 3 4 5 λ 0 1 2 3 4 5 λ * 2 0 2 4 6 8 10 I cannot type lambda, the lambda was copied from the output in j session. Tested on android only. On Sep 13, 2014 10:11 AM, "Don Guinn" wrote: > Well it defined it in W

Re: [Jprogramming] wait, what?

2014-09-12 Thread Don Guinn
Oh yes! This was in JQT 802. On Fri, Sep 12, 2014 at 8:09 PM, Raul Miller wrote: > I was using jqt 802 on desktop. > > FYI, > > -- > Raul > > > On Fri, Sep 12, 2014 at 9:09 PM, bill lam wrote: > > J implementation only allows 7 bit ascii alphabets for name. This is > > relaxed in the unofficial

Re: [Jprogramming] wait, what?

2014-09-12 Thread Don Guinn
Well it defined it in Windows 7 version of J, but couldn't access it. (152{a.)=: i.3 3 (152{a.) � names 0 aspect filler filter_size g gussian kernel_size m n r2 rho zks � � |spelling error | � | ^ It showed up as a b

Re: [Jprogramming] wait, what?

2014-09-12 Thread Raul Miller
I was using jqt 802 on desktop. FYI, -- Raul On Fri, Sep 12, 2014 at 9:09 PM, bill lam wrote: > J implementation only allows 7 bit ascii alphabets for name. This is > relaxed in the unofficial android jqt. > >(a=.152{a.)=. i.3 3 >a~ > 0 1 2 > 3 4 5 > 6 7 8 >水=.i. 2 2 >水 > 0 1

Re: [Jprogramming] Using a data arrays to send images

2014-09-12 Thread Raul Miller
Here's what I notice: In your first example, the largest possible value in Q was 9, and you referred to GRB256 even though you had not yet defined it. In your second example, the largest possible value in Q was greater than 999. Inspecting samples of the data (try 3 3 {.Q and 3 3 {. S) should ma

Re: [Jprogramming] wait, what?

2014-09-12 Thread bill lam
J implementation only allows 7 bit ascii alphabets for name. This is relaxed in the unofficial android jqt. (a=.152{a.)=. i.3 3 a~ 0 1 2 3 4 5 6 7 8 水=.i. 2 2 水 0 1 2 3 йцфы=.i.3 3 йцфы 0 1 2 3 4 5 6 7 8 On Sep 13, 2014 8:38 AM, "Raul Miller" wrote: > Apparently this is legal

Re: [Jprogramming] Using a data arrays to send images

2014-09-12 Thread Joe Bogner
Linda 10 #. Q will convert a list of decimal digits to a number http://www.jsoftware.com/jwiki/Vocabulary/numberdot#dyadic Q in your second example is a list kf numbers of varying digits. Is your goal to combine them like your first usage? If so, I dont think it will work since the numbers have

[Jprogramming] wait, what?

2014-09-12 Thread Raul Miller
Apparently this is legal: (152{a.)=: i.3 3 I was surprised. -- Raul -- For information about J forums see http://www.jsoftware.com/forums.htm

[Jprogramming] Using a data arrays to send images

2014-09-12 Thread Linda Alvord
This is the real problem I'm working on. Here's what works. load 'viewmat' GRB=:1 0 2{"1 ( #:i.8){0 255 p=: 13 :'?.(y,y)$y' ]Q=:p 10 ]R=:10 #. Q ]S=:(10$10)#:R Q-:S GRB256 viewmat Q;'Q' GRB256 viewmat S;'S' Q is a random array of data which has a corresponding color image.The da

Re: [Jprogramming] rpn calculator

2014-09-12 Thread Raul Miller
Here's a few examples that relate to how I think of A. ... (i.6) A. i.3 0 1 2 0 2 1 1 0 2 1 2 0 2 0 1 2 1 0 The number of permutations is the factorial of the number of items being permuted. (0,~.!i.6) A. i.6 0 1 2 3 4 5 0 1 2 3 5 4 0 1 2 4 3 5 0 1 3 2 4 5 0 2 1 3 4 5 1 0 2 3 4 5 Permutat

Re: [Jprogramming] rpn calculator

2014-09-12 Thread Dan Bron
Brian Schott wrote: > 1 A. b transposes the last two items of b A. is really cool. The problem with using it is coming up with the correct left-hand argument (code) for the permutation you want. A few special ones are easy to remember (particularly 0 for "do nothing", _1 for "reverse", and 1 for

Re: [Jprogramming] Question on rank conjunction's behavior regarding "unexpected" vector transposition

2014-09-12 Thread Vijay Lulla
Yes it is column-major order. To supplement Chris's point: http://www.mathworks.com/help/matlab/math/multidimensional-arrays.html On Fri, Sep 12, 2014 at 12:33 PM, Roger Hui wrote: > > For example, if an array has shape 2 3 4, then Matlab treats this as 4 > > matrices, each 2x3, while J treats i

Re: [Jprogramming] Want to see what a million looks like - even on your phone

2014-09-12 Thread Joe Bogner
Linda, thanks. This would be a good addition to add to the wiki as art. See http://jsoftware.2058.n7.nabble.com/Replace-one-item-of-a-list-tt63230.html#a63317 for reference On Fri, Sep 12, 2014 at 11:27 AM, Linda Alvord wrote: > Install J. Start J. Copy and paste code into a jqt new temp. Run

Re: [Jprogramming] Question on rank conjunction's behavior regarding "unexpected" vector transposition

2014-09-12 Thread Roger Hui
> For example, if an array has shape 2 3 4, then Matlab treats this as 4 > matrices, each 2x3, while J treats it as 2 matrices, each 3x4. This leads me to the conjecture that Matlab stores arrays in column-major order, like FORTRAN. J and APL stores arrays in row-major order. On Fri, Sep 12,

Re: [Jprogramming] rpn calculator

2014-09-12 Thread Kip Murray
Thanks very much, Dan, and thanks for the advice on verb swap. I renamed clear to clstk. --Kip On Friday, September 12, 2014, Dan Bron wrote: > Kip, > > The adverb is what you think it is, except you need to use a little trick > to workaround some limitations in the interpreter. Thus: > > >

Re: [Jprogramming] Question on rank conjunction's behavior regarding "unexpected" vector transposition

2014-09-12 Thread chris burke
Matlab has a different notion of multidimensional array than J. For example, if an array has shape 2 3 4, then Matlab treats this as 4 matrices, each 2x3, while J treats it as 2 matrices, each 3x4. I don't think it helps to try to enforce Matlab thinking on J. Also, you should try to set up data

Re: [Jprogramming] rpn calculator

2014-09-12 Thread Brian Schott
Dan, Your swapping note is an eye opener for me. (I also appreciated your answer regarding the RPN calculator. The following link suggests one particular swap using A. that might be handy, also. "1 A. b transposes the last two items of b," http://jsoftware.com/help/dictionary/dacapdot.htm On F

[Jprogramming] Want to see what a million looks like - even on your phone

2014-09-12 Thread Linda Alvord
Install J. Start J. Copy and paste code into a jqt new temp. Run code. load 'viewmat' GRB256=:1 0 2({"1) 256 256 256#:i.256^3 Q=:?(1000 1000)$ 16777216x GRB256 viewmat Q;'Q' 1000*1000*256x^3 Here's the result in the terminal: load 'viewmat' GRB256=:1 0 2({"1) 256 256 256#:i.256^3

Re: [Jprogramming] Question on rank conjunction's behavior regarding "unexpected" vector transposition

2014-09-12 Thread George Dallas
Thank you all for your responses. I think I found a solution that helps me get the shape of the result I expect by specifying at the beginning of the J sentence the shape of the result I want. For example, if I want to add the columns of the expression below and I expect a 2 by 1 vector as a result

Re: [Jprogramming] rpn calculator

2014-09-12 Thread Dan Bron
Kip wrote: > NB. swap? Oh, I meant to mention, the most fun way to swap things in J is using C. : (<0 1) C. 'AbCdEfGhI' bACdEfGhI (<4 5) C. 'AbCdEfGhI' AbCdfEGhI -Dan -- For information

Re: [Jprogramming] rpn calculator

2014-09-12 Thread Dan Bron
Kip, The adverb is what you think it is, except you need to use a little trick to workaround some limitations in the interpreter. Thus: op1Arg =: adverb def 'y],.STACK =: (_1 }. STACK), u _1 {. STACK' op2Arg =: adverb def 'y],.STACK =: ( _2 }. STACK), u/ _2 {. STACK'

[Jprogramming] rpn calculator

2014-09-12 Thread Kip Murray
I'm proud of the Reverse Polish Notation calculator shown below (think HP 50g in rpn mode). My question is, can you devise an adverb monad so that sqrt =: %: monad produces the sqrt verb below? Examples clear'' NB. Initialize global vector STACK 5 2 enter'' 5 2 1 dup'' 5 2 2 tim

Re: [Jprogramming] zlib huffman coding

2014-09-12 Thread Joe Bogner
small bug -- I had out =. (# arr) # 0 when it should have been out =. (# y) # 0 fixed: MAXBITLEN =: 15 makeFromLengths =: 3 : 0 NB. 1) Count the number of codes for each code length 'bll blct' =: |: ({.,#)/.~ /:~ y NB. 2) Find the numerical value of the smallest code for each code length: bl

Re: [Jprogramming] zlib huffman coding

2014-09-12 Thread Joe Bogner
bill, here is a crude algorithm that seems to replicate the logic from section 3.2.2 It also replicates the resultfrom the rfc in TEST1 MAXBITLEN =: 15 makeFromLengths =: 3 : 0 NB. 1) Count the number of codes for each code length 'bll blct' =: |: ({.,#)/.~ /:~ y NB. 2) Find the numerical val

Re: [Jprogramming] Extend/reduce matrix dimensions

2014-09-12 Thread Ben Gorte - CITG
Pascal Jasmin: > insertitem =: 1 : '(u"_ {. ]) , [ , u"_ }. ]' > the adverb argument is a verb that tells which item position > to insert. The verb argument is dyadic, but can be a constant > verb. Add @:] to it to just use y as the argument > 1 2: insertitem &.|: 3 3 $ 0 > 0 0 1 0 > 0 0

Re: [Jprogramming] Longest Collatz sequence

2014-09-12 Thread Henry Rich
Your method seems sound, so I suspect (without other evidence) that M. is not handling the large range of values that you need. I suggest you write an adverb to replace M. in your sentence. Use a hashtable to store the values as you find them. Roger recently published an essay with a great m