Ah thanks, I need to read the dictionary pages more carefully for those little 
things.

A couple of times I've found myself wanting to convert a number into a list of 
its digits - what is the best approach for this?

This is way I've found:

   0".,' ',.":123
1 2 3

Though it seems slightly clunky?

Also, I try to define it as a verb and I'm not sure why I'm getting a syntax 
error with it:
  
atol=: 3 :'0".,' ',.":y'
|syntax error
|   atol=:    3 :'0".,'',.":y'

Finally, how might one write that as a tacit verb?

Thanks.

On 13 Sep 2011, at 01:00, Roger Hui wrote:

>    2 x: 999r1000
> 999 1000
> 
> But suppose you didn't have 2 x: y?
> 
>    % 1 +. 999r1000
> 1000
>    (% 1&+.) 999r1000
> 999
> 
>   denominator=: %@(1&+.)
>   numerator=: % 1&+.
> 
>   ] x=: (+%)/ 20$1x
> 10946r6765
>   denominator x
> 6765
>   numerator x
> 10946
> 
> 
> 
> ----- Original Message -----
> From: David Vaughan <purpleblue...@googlemail.com>
> Date: Monday, September 12, 2011 16:48
> Subject: Re: [Jprogramming] Inserting verbs into list
> To: Programming forum <programming@jsoftware.com>
> 
>> Thanks. I did try that but for some reason thought it hadn't worked!
>> On a vaguely related note, if I have a fraction, e.g. 999r1000, 
>> how can I isolate the numerator and denominator?
>> I was thinking of formatting as a string, and then I can do this:
>> 
>>    'r' i. ":999r1000
>> 1 1 1 0 1 1 1 1
>> 
>> I was hoping to be able to go from there to by knowing where the 
>> 'r' is, but I can't think of how to do it. I'm still finding it 
>> hard to stop thinking like it's C.
>> 
>> On 12 Sep 2011, at 14:08, Raul Miller wrote:
>> 
>>> On Mon, Sep 12, 2011 at 8:57 AM, David Vaughan
>>> <purpleblue...@googlemail.com> wrote:
>>>> I'm trying to achieve this calculation:
>>>> %1+%2+%1+%1+%4+%1...
>>>> 
>>>> Essentially I want to insert +% in between each item in a 
>> list. I thought this could be achieved with / or @ but I seem to 
>> be wrong.
>>>> 
>>>> Any help would be appreciated.
>>> 
>>>    (+%)/1 2 1 1 4 1
>>> 1.39286
>>>    %(+%)/1 2 1 1 4 1
>>> 0.717949
> 
> ----------------------------------------------------------------------
> 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