The verb [: rejects all arguments with a domain error.  It has an 
exceptional role as the left tine of a fork. You CAN use forks to get 
what you want:

    d=:0 0.5 1 1.5

    NB. compare

    [: o. j. d
|domain error
|       [:o.j.d

    ([: o. j.) d
0 0j1.5708 0j3.14159 0j4.71239

    NB. These work

    ^ ([: o. j.) d
1 6.12323e_17j1 _1j1.22465e_16 _1.83697e_16j_1

    ([: ^ o.) j. d
1 6.12323e_17j1 _1j1.22465e_16 _1.83697e_16j_1

Henry would say with some justification CAN is not SHOULD.

Kip


On 12/6/2011 5:37 AM, Linda Alvord wrote:
> This is not an example where rank is not appropriate. Rank does matter. It
> is interesting as a problem and I need to think about it as a mathematical
> problem. From a programming point of view here's the issue:
>     ^@o.@j. 0 0.5 1 1.5
> 1 0j1 _1 0j_1
>     d=:0 0.5 1 1.5
>     j.d
> 0 0j0.5 0j1 0j1.5
>     o.j.d
> 0 0j1.5708 0j3.14159 0j4.71239
>    ^[:o.j.d
>    ^[:o.j.d
> |domain error
> |   ^    [:o.j.d
>    ^@o.j.d
> 1 6.12323e_17j1 _1j1.22465e_16 _1.83697e_16j_1
>    ^@:o.j.d
> 1 6.12323e_17j1 _1j1.22465e_16 _1.83697e_16j_1
>
> If you adopt my rule, then @: is really needed here and   @  could be
> eliminated.
>
> I haven't looked at the other two examples yet.
>
> Linda
>
>
> 2011/12/6 Linda Alvord<lindaalv...@verizon.net>
>
>> Can you make a simple example that looks like this  u@v@w  ?  Please use
>> actual verbs so that it is a tight little nugget that might come about in
> a
>> fairly simple mathematical situation. Use it in a situation that does not
>> require rank. Next, write it in explicit form without  @
>>
>> Here's what I would like.  Remember  foo  ?
>>
>>     foo=: 13 :'an expression with x's and y's and three verbs like # , %: ,
>> ? or  * '
>>
>>
>> Also:
>>
>> Let us use   [: u v    or  u@:v  as we like, and specify a rank when we
>> need one.
>>
>> I think I could live with:
>>
>> Let us use   [: u v   unless rank is involved.  Only use u@:v  if rank is
>> needed, thus  @  vanishes from the planet.
>>
>>
>> Linda
>>
>>
>> -----Original Message-----
>> From: programming-boun...@jsoftware.com
>> [mailto:programming-boun...@jsoftware.com] On Behalf Of Henry Rich
>> Sent: Monday, December 05, 2011 10:08 PM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Turkey Roll - Challenge 2
>>
>> If you are OK with @: , then we agree.  @ is hard for beginners.
>>
>>
>> u@v  is equivalent to   u@:v"v   or  ([: u v)"v
>>
>> u@v@w is u@:v"v@:w"w  or  ([:   ([: u v)"v   w)"w
>>
>> Henry Rich
>>
>> On 12/5/2011 9:57 PM, Linda Alvord wrote:
>>> Can you make a simple example that looks like this  u@v@w  .  Is it
>> possible
>>> to write an explicit version that will create a tacit expression to do
>> the
>>> same thing?
>>>
>>> I don't have a problem with  @:  .  My concern is only with  @
>>>
>>> Linda
>>>
>>> -----Original Message-----
>>> From: programming-boun...@jsoftware.com
>>> [mailto:programming-boun...@jsoftware.com] On Behalf Of Henry Rich
>>> Sent: Monday, December 05, 2011 9:28 PM
>>> To: Programming forum
>>> Subject: Re: [Jprogramming] Turkey Roll - Challenge 2
>>>
>>> I don't understand why u@v is anything other than 'right to left'.  It
>>> means do v, then do u.  u@v@w means w, then v, then u.
>>>
>>> The complication of @ is not its ordering, it's its rank.  In my classes
>>> I teach @: as a primitive.  We don't use [:, or @  .
>>>
>>> Henry Rich
>>>
>>> On 12/5/2011 9:15 PM, Linda Alvord wrote:
>>>>
>>>> Compare your expression for  dice :
>>>>
>>>>       faces=: {&' o'@((i.3 3)e.&":"1])&.>4 80 840 8620 86420 865320
>>>>       faces
>>>> ------T-----T-----T-----T-----T-----┐
>>>> │     │o    │o    │o   o│o   o│o   o│
>>>> │  o  │     │  o  │     │  o  │o   o│
>>>> │     │    o│    o│o   o│o   o│o   o│
>>>> L-----+-----+-----+-----+-----+------
>>>>
>>>> With Kip Murray's version:
>>>>
>>>>        one =:   '   ',' o ',:'   '
>>>>        two =:   'o  ','   ',:'  o'
>>>>       three =: 'o  ',' o ',:'  o'
>>>>       four =:  'o o','   ',:'o o'
>>>>       five =:  'o o',' o ',:'o o'
>>>>       six =:   'o o','o o',:'o o'
>>>>       ]dice =: one;two;three;four;five;six
>>>> ----T---T---T---T---T---┐
>>>> │   │o  │o  │o o│o o│o o│
>>>> │ o │   │ o │   │ o │o o│
>>>> │   │  o│  o│o o│o o│o o│
>>>> L---+---+---+---+---+----
>>>>
>>>> Your dice are great looking! However that change has greatly increased
>> the
>>>> complexity of the code.  Also, there is a condition of the challenge to
>>>> exclude  @  in each expression. This requirement encourages considering
>>> the
>>>> execution from the right toward the left. In your example  4 80 840
>> 8620
>>>> 86420 865320   could  be puzzling to a beginner. Your other ideas are
>>>> thoughtful ideas to incorporate in an actual design of a program. At
>> this
>>>> stage, I'm trying to raise issues that can be discussed and explored
>>>> further.
>>>>
>>>>    From your design so far, is it possible for you to capture the actual
>>> values
>>>> of the  and display them following each   toss  ?  It is this data that
>>> will
>>>> be useful as you finish the challenge.
>>>>
>>>> Linda
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: programming-boun...@jsoftware.com
>>>> [mailto:programming-boun...@jsoftware.com] On Behalf Of Raul Miller
>>>> Sent: Monday, December 05, 2011 9:50 AM
>>>> To: Programming forum
>>>> Subject: Re: [Jprogramming] Turkey Roll - Challenge 2
>>>>
>>>> Personally, I have been baffled by a number of the choices and
>>> requirements
>>>> here.  And, by this, I mean that I do not understand them.
>>>>
>>>> That said, here is my current interpretation of a mix of some of the
>>>> statements expressed here, about what is being accomplished:
>>>>
>>>> faces=: {&' o'@((i.3 3)e.&":"1])&.>4 80 840 8620 86420 865320
>>>> toss=: (] {~ (?@$ #)) ".bind 'faces'
>>>>
>>>> Example use, with ascii box drawing enabled:
>>>>
>>>>       toss 2 10
>>>> +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
>>>> |o    |o    |o   o|o    |o    |o    |o    |o   o|o   o|o   o|
>>>> |  o  |  o  |  o  |  o  |  o  |     |     |     |  o  |o   o|
>>>> |    o|    o|o   o|    o|    o|    o|    o|o   o|o   o|o   o|
>>>> +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
>>>> |o    |o   o|o    |o   o|o   o|o    |o    |o    |o   o|o    |
>>>> |  o  |  o  |     |  o  |     |     |     |     |     |     |
>>>> |    o|o   o|    o|o   o|o   o|    o|    o|    o|o   o|    o|
>>>> +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
>>>>       toss 2 10
>>>> +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
>>>> |o    |o    |o   o|o    |o   o|o    |o   o|o   o|o   o|o    |
>>>> |     |     |     |  o  |o   o|  o  |     |  o  |o   o|     |
>>>> |    o|    o|o   o|    o|o   o|    o|o   o|o   o|o   o|    o|
>>>> +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
>>>> |o   o|o    |o   o|o   o|o   o|o   o|     |o   o|o   o|o   o|
>>>> |     |     |  o  |     |     |  o  |  o  |     |     |     |
>>>> |o   o|    o|o   o|o   o|o   o|o   o|     |o   o|o   o|o   o|
>>>> +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
>>>>
>>>> Notes:
>>>>
>>>> 1. I spaced my pips out wider, horizontally, than the original.  I
> think
>>>> this looks better.
>>>> 2. toss has 'faces' as an implicit dependency
>>>> 3. I can change the number of dice being tossed by changing the
> argument
>>> to
>>>> toss
>>>>
>>>> In my opinion, this is not a very good design.  In "real life" code, I
>>>> would either replace (". bind 'faces') with (faces) or I would make it
>> an
>>>> argument to the function.
>>>>
>>>> I could probably compress a few characters out of the definition of
>> faces,
>>>> but it would become more mysterious if I did so.
>>>>
>>> ----------------------------------------------------------------------
>>> 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