Strange, but sorted now. I've just written another verb and am getting another
spelling error which I don't understand - none of this was copied and pasted:
pell =: 3 : 0
a =. x: cf y
if. 0=2|#a do. a =. (] , }.@}:) a end.
{. 2&x: (+%)/ a
)
|spelling error
| {. 2&x: (+%)/ a
| ^
| pell=: 3 :0
If I type it 'manually' it works.
On 18 Oct 2011, at 18:26, Raul Miller wrote:
> If I copy and paste this into a temp file, and load it, I get the same
> spelling error you got.
>
> If I replace the load keyword in my session with a.i.30 }. 41 {. 1!:1<
> I get:
> 50 43 114 13 10 226 128 139 226 128 139
>
> So it looks like you have a couple invisible white space unicode
> sequences which J currently does not recognize as valid white space.
>
> Confirming this, in my J6.02 session, if I position the cursor to the
> right of the 'w' in while and then move my cursor one character to the
> left, and hit delete twice, the 'while.' keyword changes color, and
> when I load the file I do not get the spelling error.
>
> FYI,
>
> --
> Raul
>
>
> On Tue, Oct 18, 2011 at 1:09 PM, David Vaughan
> <[email protected]> wrote:
>> Hmm, now I'm getting a spelling error which doesn't seem to make sense:
>>
>> cf =: 3 : 0
>> r=.%:y
>> a=.<.1r2+r
>> while. ({:a)~:2*{.a do. a=.a,<.1r2+{:r ] r=.r,%({:r)-{:a end.
>> ]a
>> )
>> |spelling error
>> |
>> | ^
>> | cf=: 3 :0
>>
>> It's like it's saying the error is above the first line. Also this is no
>> different to the version I had before aside from the correction in the while
>> loop.
>>
>> On 18 Oct 2011, at 18:00, Raul Miller wrote:
>>
>>> The first element of a is always 1.
>>>
>>> The last element of a is always an integer and so can never be 0.5.
>>>
>>> So the loop can never terminate.
>>>
>>> --
>>> Raul
>>>
>>> On Tue, Oct 18, 2011 at 12:52 PM, David Vaughan
>>> <[email protected]> wrote:
>>>> Why does this not work? I had to interrupt it because it just froze doing
>>>> nothing.
>>>>
>>>> cf =: 3 : 0
>>>> r=.%:y
>>>> a=.<.1r2+r
>>>> while. ({.a)~:2*{:a do. a=.a,<.1r2+{:r ] r=.r,1%({:r)-{:a end.
>>>> ]a
>>>> )
>>>> cf 2
>>>> |attention interrupt: cf
>>>> | cf 2
>>>>
>>>>
>>>> On 18 Oct 2011, at 17:23, Raul Miller wrote:
>>>>
>>>>> The best I can think of at the moment is using x: on the floating
>>>>> point value for an initial value and then newton's method to gain the
>>>>> extra precision you want.
>>>>>
>>>>> --
>>>>> Raul
>>>>>
>>>>> On Tue, Oct 18, 2011 at 12:09 PM, David Vaughan
>>>>> <[email protected]> wrote:
>>>>>> I'm hoping to write a verb to compute the continued fraction expansion
>>>>>> of a square root. I've done it in Java though there are accuracy issues
>>>>>> with floating points and speed issues with using exact numbers (you end
>>>>>> up multiplying massive numbers in some cases). Is J equipped to deal
>>>>>> with these problems or should I be looking for an alternative method
>>>>>> entirely?
>>>>>>
>>>>>> On 18 Oct 2011, at 16:50, Raul Miller wrote:
>>>>>>
>>>>>>> On Tue, Oct 18, 2011 at 11:30 AM, David Vaughan
>>>>>>> <[email protected]> wrote:
>>>>>>>> Can J represent surds exactly instead of reverting to floating point?
>>>>>>>> It would be more convenient if I could do that rather than storing the
>>>>>>>> squared version.
>>>>>>>
>>>>>>> Yes, but by generating a verb which would generate the floating point
>>>>>>> value and not as a number.
>>>>>>>
>>>>>>> cubeRootOf5=: %:&5 bind 3
>>>>>>>
>>>>>>> Of course you can manipulate the resulting numbers but those results
>>>>>>> are still floating point:
>>>>>>>
>>>>>>> (cubeRootOf5 ^ 3:) ''
>>>>>>> 5
>>>>>>> 5-(cubeRootOf5 ^ 3:) ''
>>>>>>> 8.88178e_16
>>>>>>>
>>>>>>> That said, in some cases, J can clean up floating point discrepancies
>>>>>>>
>>>>>>> 5-x:(cubeRootOf5 ^ 3:) ''
>>>>>>> 0
>>>>>>>
>>>>>>> but that's from direct manipulation of the values and does not care
>>>>>>> about delayed evaluation:
>>>>>>>
>>>>>>> 5-x:((3 %:5) ^ 3:) ''
>>>>>>> 0
>>>>>>>
>>>>>>> Anyways, J implements the data structures to support symbolic
>>>>>>> manipulation but it does not have a particularly large library of
>>>>>>> prebuilt symbolic manipulation routines.
>>>>>>>
>>>>>>> FYI,
>>>>>>>
>>>>>>> --
>>>>>>> Raul
>>>>>>> ----------------------------------------------------------------------
>>>>>>> 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