''$,  ''
|length error

This one doesn't work when applied to an empty. Sometimes that's desirable. The others work on empties.

Note that
   '' ($,) A

has the same result as

   '' $ , A

but the former version is backed by special code & doesn't actually do the enfile.

Henry Rich

On 9/3/2012 4:00 AM, Linda Alvord wrote:
Thanks to all!

Kip Murray showed me that I am dealing with a noun that is a table and not an 
atom! His solution  ,A  turns a list into an atom.

     ]A=:1 1$4
4
    ]C=:''
    ]B=:3 5 7
    ]B=:3 5 7
3 5 7

Two alternatives helped:

     B+A
|length error
|   B    +A
    B+{.@,A     NB. Bill Lam
7 8 9
    B+''$,AN    NB. Henry Rich
7 8 9
    B+{.,A
7 8 9

I add the third because I try to avoid  @  and I create the problem most often 
by using  {

All work if the noun is empty.
    C+{.@,A
    C+''$,A
    C+{.,A

So this thread really should be called:  Table to Atom - First time around.

Linda

-----Original Message-----
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Henry Rich
Sent: Monday, September 03, 2012 1:16 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Scalar to Vector - Yet again

The easiest way to make a scalar of an arbitrary noun is

     ''($,)A

which will work on anything except an empty A.

Henry Rich

On 9/2/2012 10:52 PM, Roger Hui wrote:
You are (probably) trying to undo years of conditioning in APL, which
has the misguided "singleton extension":  In APL,
     2 3 4 + (?n⍴1)⍴5
worked.  Singleton extension is undesirable because it complicates the
rules for the rank operator.

It feels wrong to have to do things like this every time I want to
use the result of a previous computation called  A .

Alternatively, it feels wrong that A is non-scalar as computed.



On Sun, Sep 2, 2012 at 6:48 PM, Linda Alvord <lindaalv...@verizon.net>wrote:

I finally think I know what I don't know. I want to turn "table" A
into a scalar (which it happens to look like).

      A
4
     $A
1 1
     B=:3 5 7
     A+B
|length error
|   A    +B
     (,A)+B
|length error
|   (,A)    +B
     (,3$A)+B
7 9 11
     (,($B)$A)+B
7 9 11

It feels wrong to have to do things like this every time I want to
use the result of a previous computation called  A .

Linda

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda
Alvord
Sent: Saturday, September 01, 2012 7:26 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Scalar to Vector - Yet again

I wasn't thinking.  A isn't a scalar. I even knew it had shape 1 1 .

      A
4
     $A
1 1
     $3 2
2
     2$A
4
4
     3 2 + ,2$A
7 6

This works!  Thanks.

Linda

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of km
Sent: Saturday, September 01, 2012 6:10 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Scalar to Vector - Yet again

,4 is a vector

Sent from my iPad


On Sep 1, 2012, at 4:56 PM, "Linda Alvord" <lindaalv...@verizon.net>
wrote:

I vow to remember how to do this, and several months later I forget
and can't find it

anywhere.  Is there some way to get to the example from the
vocabulary
page?
Maybe I can remember that.



    A=:1 1$4

    3 2 + A

|length error
|   3 2    +A



Thanks.



Linda

--------------------------------------------------------------------
-- For information about J forums see
http://www.jsoftware.com/forums.htm
---------------------------------------------------------------------
- For information about J forums see
http://www.jsoftware.com/forums.htm

---------------------------------------------------------------------
- For information about J forums see
http://www.jsoftware.com/forums.htm

---------------------------------------------------------------------
- For information about J forums see
http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to