I see that the algorithm you suggested only works on linked lists. Is there a 
way to model linked lists in J?

On 20 Nov 2011, at 15:05, Henry Rich wrote:

> You have to use ~. so that the list doesn't keep growing when a match is 
> found.  ^:_ would run forever then, since it stops when two successive 
> results are identical.
> 
> This method takes O(*:n) time because of the ~.@,  .  If that's a 
> problem, you might want to look into the very elegant Floyd's Cycle 
> Algorithm.
> 
> Henry Rich
> 
> On 11/20/2011 8:51 AM, David Vaughan wrote:
>> This seems to have the behaviour I'm looking for, thanks.
>> 
>> I don't understand why though. I can see that each result of f is being 
>> stored in a list as the verb is being applied each time, but I don't 
>> understand why ~.@, enables this.
>> 
>> On 20 Nov 2011, at 13:31, Raul Miller wrote:
>> 
>>> You can do
>>> (~.@, f@{:)^:_ y
>>> 
>>> But I am not sure how to work<x into this.
>>> 
>>> --
>>> Raul
>>> 
>>> On Sun, Nov 20, 2011 at 5:36 AM, David Vaughan<[email protected]
>>>> wrote:
>>> 
>>>> If I'm doing f^:(<x) y, can I write an expression so that f is repeatedly
>>>> applied to y until the result has come up before?
>>>> ----------------------------------------------------------------------
>>>> 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