Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-18 Thread Raul Miller
That is what we have been trying to explain. ;)

That said it is also worth noting that Jose included some deliberate
(though inconsequential) other inefficiencies in his implementation.
Can you spot them?

Thanks,

-- 
Raul


On Mon, Nov 18, 2013 at 12:22 AM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 I think there is a bug or needless slowdown in the implicit code 
 interpreter.

 before it disapears from my edit bufffers, a slight variation on your code
 a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2
 a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2
((( $:@:}.)^:(6:{.))^:_) @: dh :: (__)  a2
 8 5 2 2 2 2 2 2 2 2 2 2 2

 while the code does indeed exit after the first match, ^:0 is extremely slow 
 at returning 'y', or dh is extremely slow at amending the head of a long list.

 for this version, I don't understand why it does not also break out:

   pD =: 1!:22


({.`}.@.(6:{.)^:_@:pD@:+:)1 2 1 4 5 2
 2 4 2 8 10 4
 8



 
 From: Jose Mario Quintana jose.mario.quint...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Sent: Sunday, November 17, 2013 11:32:06 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?


 We can check it out,

 dh=. ([ smoutput)@:(+:@:(0({::)) 0} ])

 ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
 4 1 3 2 4 5 2
 2 3 2 4 5 2
 6 2 4 5 2
 4 4 5 2
 8 5 2
 8

 So, v (+: in this case) is evaluated only until the condition is met.  What
 happens is that if the verb v is not really expensive to evaluate or if the
 condition is met near the end, the extra complication is not worth it.

 It is too late in the evening now but tomorrow I will elaborate on a direct
 support via a couple of new alternative primitives, stay tuned... ;)


 On Sun, Nov 17, 2013 at 8:48 PM, Pascal Jasmin godspiral2...@yahoo.cawrote:

 Thank you so much.  A lot of the motivation for the question was hoping to
 have my thinking expanded.

 For those following along, the use of 0{:: is interesting as an
 alternative to {. because it will generate an error when the list runs out.

 Your second version advertised as lazy, though, seems to evaluate the
 whole list (assumption from timings)

 a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2

 a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2


ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a'
 0.654649/sec 14.6902MB
ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a2'
 275.307/sec 0.149376MB
ts '{.@(}.^:(6:{.)^:_@: +:)  a2'
 637.106/sec 0.137088MB
ts '{.@(}.^:(6:{.)^:_@: +:)  a'
 1.14031/sec 13.6375MB


  I have thought that a direct tacit support for this kind of situations
 would be welcome; I will
 elaborate more on this subject soon.

 Would your thoughts be towards a break. function in tacit code?  From your
 above code, it would seem that generating an error would let us break out.


 
 From: Jose Mario Quintana jose.mario.quint...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Sent: Sunday, November 17, 2013 7:22:43 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitionspossible?


 Pascal Jasmin writes:

   But I'd like to see the first before I ask for another, and the approach
 of
   finding them all and then returning the first is not practical.

 Arie Groeneveld writes:

   {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2

 8


 Presumably is not practical because the verb v in the actual application
 is expensive to compute (+: in the toy example).  However, +: is computed
 for each of the items of the argument.  If that were the case then the
 following lazy variation could help,


dh=. +:@:(0({::)) 0} ]
({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
 8
({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2
 None found

 Extra code might also be necessary to avoid a potential premature
 convergence.  Furthermore, for many years I have thought that a direct
 tacit support for this kind of situations would be welcome; I will
 elaborate more on this subject soon.


 On Sun, Nov 17, 2013 at 4:24 AM, Aai agroeneveld...@gmail.com wrote:

 $:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
  8
 
  much slower
 
 {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
  8
 
  But I prefer Raul's solution.
 
 
 
 
  On 17-11-13 03:38, Pascal Jasmin wrote:
 
  I spent some time describing the application.  You can also think of the
  application as search every web page on every ipv4 until the first
  interesting thing is found.  Maybe I care about a 2nd interesting thing,
  maybe I don't.  But I'd like to see the first before I ask for another,
 and
  the approach of finding them all and then returning the first is not
  practical.
 
  The explicit version I provided is not unworkable.  I was hoping that
  there is a version with {. and $:@:}.
 
 
  - Original Message -
  From: Raul Miller rauldmil...@gmail.com
  To: Programming forum programm...@jsoftware.com
  Cc

Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-18 Thread Jose Mario Quintana
See the verb trigger ([.) and the adverb trap (].) in the article J
Functional Programming Extensions appearing in the latest issue of the
Journal of J (October 2013) at http://journalofj.com/ .  I found the whole
issue enjoyable.


On Sun, Nov 17, 2013 at 11:32 PM, Jose Mario Quintana 
jose.mario.quint...@gmail.com wrote:

 We can check it out,

 dh=. ([ smoutput)@:(+:@:(0({::)) 0} ])


 ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
 4 1 3 2 4 5 2
 2 3 2 4 5 2
 6 2 4 5 2
 4 4 5 2
 8 5 2
 8

 So, v (+: in this case) is evaluated only until the condition is met.
 What happens is that if the verb v is not really expensive to evaluate or
 if the condition is met near the end, the extra complication is not worth
 it.

 It is too late in the evening now but tomorrow I will elaborate on a
 direct support via a couple of new alternative primitives, stay tuned... ;)


 On Sun, Nov 17, 2013 at 8:48 PM, Pascal Jasmin godspiral2...@yahoo.cawrote:

 Thank you so much.  A lot of the motivation for the question was hoping
 to have my thinking expanded.

 For those following along, the use of 0{:: is interesting as an
 alternative to {. because it will generate an error when the list runs out.

 Your second version advertised as lazy, though, seems to evaluate the
 whole list (assumption from timings)

 a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2

 a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2


ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a'
 0.654649/sec 14.6902MB
ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a2'
 275.307/sec 0.149376MB
ts '{.@(}.^:(6:{.)^:_@: +:)  a2'
 637.106/sec 0.137088MB
ts '{.@(}.^:(6:{.)^:_@: +:)  a'
 1.14031/sec 13.6375MB


  I have thought that a direct tacit support for this kind of situations
 would be welcome; I will
 elaborate more on this subject soon.

 Would your thoughts be towards a break. function in tacit code?  From
 your above code, it would seem that generating an error would let us break
 out.


 
 From: Jose Mario Quintana jose.mario.quint...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Sent: Sunday, November 17, 2013 7:22:43 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitionspossible?


 Pascal Jasmin writes:

   But I'd like to see the first before I ask for another, and the approach
 of
   finding them all and then returning the first is not practical.

 Arie Groeneveld writes:

   {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2

 8


 Presumably is not practical because the verb v in the actual application
 is expensive to compute (+: in the toy example).  However, +: is computed
 for each of the items of the argument.  If that were the case then the
 following lazy variation could help,


dh=. +:@:(0({::)) 0} ]
({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
 8
({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2
 None found

 Extra code might also be necessary to avoid a potential premature
 convergence.  Furthermore, for many years I have thought that a direct
 tacit support for this kind of situations would be welcome; I will
 elaborate more on this subject soon.


 On Sun, Nov 17, 2013 at 4:24 AM, Aai agroeneveld...@gmail.com wrote:

 $:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
  8
 
  much slower
 
 {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
  8
 
  But I prefer Raul's solution.
 
 
 
 
  On 17-11-13 03:38, Pascal Jasmin wrote:
 
  I spent some time describing the application.  You can also think of
 the
  application as search every web page on every ipv4 until the first
  interesting thing is found.  Maybe I care about a 2nd interesting
 thing,
  maybe I don't.  But I'd like to see the first before I ask for
 another, and
  the approach of finding them all and then returning the first is not
  practical.
 
  The explicit version I provided is not unworkable.  I was hoping that
  there is a version with {. and $:@:}.
 
 
  - Original Message -
  From: Raul Miller rauldmil...@gmail.com
  To: Programming forum programm...@jsoftware.com
  Cc:
  Sent: Saturday, November 16, 2013 8:56:03 PM
  Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
  definitions  possible?
 
  ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
  8
  ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
  4 2 6 4
 
  Now you might argue that this is not the same thing. But it is the same
  result.
 
  It's just faster to compute this way. And, ok, I understand that speed
  is not necessarily desirable. But I think in this case you might want
  to just use a different language.
 
 
  --
  Met vriendelijke groet,
  @@i = Arie Groeneveld
 
 
  --
  For information about J forums see http://www.jsoftware.com/forums.htm

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

Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-17 Thread Aai

   $:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
8

much slower

   {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
8

But I prefer Raul's solution.



On 17-11-13 03:38, Pascal Jasmin wrote:

I spent some time describing the application.  You can also think of the 
application as search every web page on every ipv4 until the first interesting 
thing is found.  Maybe I care about a 2nd interesting thing, maybe I don't.  
But I'd like to see the first before I ask for another, and the approach of 
finding them all and then returning the first is not practical.

The explicit version I provided is not unworkable.  I was hoping that there is 
a version with {. and $:@:}.


- Original Message -
From: Raul Miller rauldmil...@gmail.com
To: Programming forum programm...@jsoftware.com
Cc:
Sent: Saturday, November 16, 2013 8:56:03 PM
Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions  
possible?

({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
8
({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
4 2 6 4

Now you might argue that this is not the same thing. But it is the same result.

It's just faster to compute this way. And, ok, I understand that speed
is not necessarily desirable. But I think in this case you might want
to just use a different language.



--
Met vriendelijke groet,
@@i = Arie Groeneveld

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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-17 Thread Don Guinn
$: is recursive where the explicit version it iterative.
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-17 Thread Jose Mario Quintana
Pascal Jasmin writes:

  But I'd like to see the first before I ask for another, and the approach
of
  finding them all and then returning the first is not practical.

Arie Groeneveld writes:

   {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2

8


Presumably is not practical because the verb v in the actual application
is expensive to compute (+: in the toy example).  However, +: is computed
for each of the items of the argument.  If that were the case then the
following lazy variation could help,


   dh=. +:@:(0({::)) 0} ]
   ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
8
   ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2
None found

Extra code might also be necessary to avoid a potential premature
convergence.  Furthermore, for many years I have thought that a direct
tacit support for this kind of situations would be welcome; I will
elaborate more on this subject soon.


On Sun, Nov 17, 2013 at 4:24 AM, Aai agroeneveld...@gmail.com wrote:

$:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
 8

 much slower

{.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
 8

 But I prefer Raul's solution.




 On 17-11-13 03:38, Pascal Jasmin wrote:

 I spent some time describing the application.  You can also think of the
 application as search every web page on every ipv4 until the first
 interesting thing is found.  Maybe I care about a 2nd interesting thing,
 maybe I don't.  But I'd like to see the first before I ask for another, and
 the approach of finding them all and then returning the first is not
 practical.

 The explicit version I provided is not unworkable.  I was hoping that
 there is a version with {. and $:@:}.


 - Original Message -
 From: Raul Miller rauldmil...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 8:56:03 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitions  possible?

 ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
 8
 ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
 4 2 6 4

 Now you might argue that this is not the same thing. But it is the same
 result.

 It's just faster to compute this way. And, ok, I understand that speed
 is not necessarily desirable. But I think in this case you might want
 to just use a different language.


 --
 Met vriendelijke groet,
 @@i = Arie Groeneveld


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

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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-17 Thread Pascal Jasmin
Thank you so much.  A lot of the motivation for the question was hoping to have 
my thinking expanded.

For those following along, the use of 0{:: is interesting as an alternative to 
{. because it will generate an error when the list runs out.

Your second version advertised as lazy, though, seems to evaluate the whole 
list (assumption from timings)

a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2

a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2


   ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a'
0.654649/sec 14.6902MB
   ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a2'
275.307/sec 0.149376MB
   ts '{.@(}.^:(6:{.)^:_@: +:)  a2'
637.106/sec 0.137088MB
   ts '{.@(}.^:(6:{.)^:_@: +:)  a'
1.14031/sec 13.6375MB


 I have thought that a direct tacit support for this kind of situations would 
be welcome; I will
elaborate more on this subject soon.

Would your thoughts be towards a break. function in tacit code?  From your 
above code, it would seem that generating an error would let us break out.



From: Jose Mario Quintana jose.mario.quint...@gmail.com
To: Programming forum programm...@jsoftware.com 
Sent: Sunday, November 17, 2013 7:22:43 PM
Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions
possible?


Pascal Jasmin writes:

  But I'd like to see the first before I ask for another, and the approach
of
  finding them all and then returning the first is not practical.

Arie Groeneveld writes:

      {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2

8


Presumably is not practical because the verb v in the actual application
is expensive to compute (+: in the toy example).  However, +: is computed
for each of the items of the argument.  If that were the case then the
following lazy variation could help,


   dh=. +:@:(0({::)) 0} ]
   ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
8
   ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2
None found

Extra code might also be necessary to avoid a potential premature
convergence.  Furthermore, for many years I have thought that a direct
tacit support for this kind of situations would be welcome; I will
elaborate more on this subject soon.


On Sun, Nov 17, 2013 at 4:24 AM, Aai agroeneveld...@gmail.com wrote:

    $:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
 8

 much slower

    {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
 8

 But I prefer Raul's solution.




 On 17-11-13 03:38, Pascal Jasmin wrote:

 I spent some time describing the application.  You can also think of the
 application as search every web page on every ipv4 until the first
 interesting thing is found.  Maybe I care about a 2nd interesting thing,
 maybe I don't.  But I'd like to see the first before I ask for another, and
 the approach of finding them all and then returning the first is not
 practical.

 The explicit version I provided is not unworkable.  I was hoping that
 there is a version with {. and $:@:}.


 - Original Message -
 From: Raul Miller rauldmil...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 8:56:03 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitions      possible?

     ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
 8
     ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
 4 2 6 4

 Now you might argue that this is not the same thing. But it is the same
 result.

 It's just faster to compute this way. And, ok, I understand that speed
 is not necessarily desirable. But I think in this case you might want
 to just use a different language.


 --
 Met vriendelijke groet,
 @@i = Arie Groeneveld


 --
 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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-17 Thread Jose Mario Quintana
We can check it out,

dh=. ([ smoutput)@:(+:@:(0({::)) 0} ])

({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
4 1 3 2 4 5 2
2 3 2 4 5 2
6 2 4 5 2
4 4 5 2
8 5 2
8

So, v (+: in this case) is evaluated only until the condition is met.  What
happens is that if the verb v is not really expensive to evaluate or if the
condition is met near the end, the extra complication is not worth it.

It is too late in the evening now but tomorrow I will elaborate on a direct
support via a couple of new alternative primitives, stay tuned... ;)


On Sun, Nov 17, 2013 at 8:48 PM, Pascal Jasmin godspiral2...@yahoo.cawrote:

 Thank you so much.  A lot of the motivation for the question was hoping to
 have my thinking expanded.

 For those following along, the use of 0{:: is interesting as an
 alternative to {. because it will generate an error when the list runs out.

 Your second version advertised as lazy, though, seems to evaluate the
 whole list (assumption from timings)

 a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2

 a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2


ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a'
 0.654649/sec 14.6902MB
ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a2'
 275.307/sec 0.149376MB
ts '{.@(}.^:(6:{.)^:_@: +:)  a2'
 637.106/sec 0.137088MB
ts '{.@(}.^:(6:{.)^:_@: +:)  a'
 1.14031/sec 13.6375MB


  I have thought that a direct tacit support for this kind of situations
 would be welcome; I will
 elaborate more on this subject soon.

 Would your thoughts be towards a break. function in tacit code?  From your
 above code, it would seem that generating an error would let us break out.


 
 From: Jose Mario Quintana jose.mario.quint...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Sent: Sunday, November 17, 2013 7:22:43 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitionspossible?


 Pascal Jasmin writes:

   But I'd like to see the first before I ask for another, and the approach
 of
   finding them all and then returning the first is not practical.

 Arie Groeneveld writes:

   {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2

 8


 Presumably is not practical because the verb v in the actual application
 is expensive to compute (+: in the toy example).  However, +: is computed
 for each of the items of the argument.  If that were the case then the
 following lazy variation could help,


dh=. +:@:(0({::)) 0} ]
({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
 8
({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2
 None found

 Extra code might also be necessary to avoid a potential premature
 convergence.  Furthermore, for many years I have thought that a direct
 tacit support for this kind of situations would be welcome; I will
 elaborate more on this subject soon.


 On Sun, Nov 17, 2013 at 4:24 AM, Aai agroeneveld...@gmail.com wrote:

 $:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
  8
 
  much slower
 
 {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
  8
 
  But I prefer Raul's solution.
 
 
 
 
  On 17-11-13 03:38, Pascal Jasmin wrote:
 
  I spent some time describing the application.  You can also think of the
  application as search every web page on every ipv4 until the first
  interesting thing is found.  Maybe I care about a 2nd interesting thing,
  maybe I don't.  But I'd like to see the first before I ask for another,
 and
  the approach of finding them all and then returning the first is not
  practical.
 
  The explicit version I provided is not unworkable.  I was hoping that
  there is a version with {. and $:@:}.
 
 
  - Original Message -
  From: Raul Miller rauldmil...@gmail.com
  To: Programming forum programm...@jsoftware.com
  Cc:
  Sent: Saturday, November 16, 2013 8:56:03 PM
  Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
  definitions  possible?
 
  ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
  8
  ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
  4 2 6 4
 
  Now you might argue that this is not the same thing. But it is the same
  result.
 
  It's just faster to compute this way. And, ok, I understand that speed
  is not necessarily desirable. But I think in this case you might want
  to just use a different language.
 
 
  --
  Met vriendelijke groet,
  @@i = Arie Groeneveld
 
 
  --
  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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-17 Thread Pascal Jasmin
I think there is a bug or needless slowdown in the implicit code interpreter.

before it disapears from my edit bufffers, a slight variation on your code
a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2
a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2
   ((( $:@:}.)^:(6:{.))^:_) @: dh :: (__)  a2
8 5 2 2 2 2 2 2 2 2 2 2 2

while the code does indeed exit after the first match, ^:0 is extremely slow at 
returning 'y', or dh is extremely slow at amending the head of a long list.

for this version, I don't understand why it does not also break out:

  pD =: 1!:22


   ({.`}.@.(6:{.)^:_@:pD@:+:)1 2 1 4 5 2
2 4 2 8 10 4
8




From: Jose Mario Quintana jose.mario.quint...@gmail.com
To: Programming forum programm...@jsoftware.com 
Sent: Sunday, November 17, 2013 11:32:06 PM
Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions
possible?


We can check it out,

    dh=. ([ smoutput)@:(+:@:(0({::)) 0} ])

    ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
4 1 3 2 4 5 2
2 3 2 4 5 2
6 2 4 5 2
4 4 5 2
8 5 2
8

So, v (+: in this case) is evaluated only until the condition is met.  What
happens is that if the verb v is not really expensive to evaluate or if the
condition is met near the end, the extra complication is not worth it.

It is too late in the evening now but tomorrow I will elaborate on a direct
support via a couple of new alternative primitives, stay tuned... ;)


On Sun, Nov 17, 2013 at 8:48 PM, Pascal Jasmin godspiral2...@yahoo.cawrote:

 Thank you so much.  A lot of the motivation for the question was hoping to
 have my thinking expanded.

 For those following along, the use of 0{:: is interesting as an
 alternative to {. because it will generate an error when the list runs out.

 Your second version advertised as lazy, though, seems to evaluate the
 whole list (assumption from timings)

 a =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e5 $ 2

 a2 =. ( 1e3 $ 2) , 2 1 3 2 4 5 2, 1e1 $ 2


    ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a'
 0.654649/sec 14.6902MB
    ts '({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: (__)  a2'
 275.307/sec 0.149376MB
    ts '{.@(}.^:(6:{.)^:_@: +:)  a2'
 637.106/sec 0.137088MB
    ts '{.@(}.^:(6:{.)^:_@: +:)  a'
 1.14031/sec 13.6375MB


  I have thought that a direct tacit support for this kind of situations
 would be welcome; I will
 elaborate more on this subject soon.

 Would your thoughts be towards a break. function in tacit code?  From your
 above code, it would seem that generating an error would let us break out.


 
 From: Jose Mario Quintana jose.mario.quint...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Sent: Sunday, November 17, 2013 7:22:43 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitions    possible?


 Pascal Jasmin writes:

   But I'd like to see the first before I ask for another, and the approach
 of
   finding them all and then returning the first is not practical.

 Arie Groeneveld writes:

       {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2

 8


 Presumably is not practical because the verb v in the actual application
 is expensive to compute (+: in the toy example).  However, +: is computed
 for each of the items of the argument.  If that were the case then the
 following lazy variation could help,


    dh=. +:@:(0({::)) 0} ]
    ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2 4 5 2
 8
    ({.@:((dh @: }.^:(6:{.)^:_)) @: dh) :: ('None found'_) 2 1 3 2
 None found

 Extra code might also be necessary to avoid a potential premature
 convergence.  Furthermore, for many years I have thought that a direct
 tacit support for this kind of situations would be welcome; I will
 elaborate more on this subject soon.


 On Sun, Nov 17, 2013 at 4:24 AM, Aai agroeneveld...@gmail.com wrote:

     $:@}.`{.@.(6{.) +: 2 1 3 2 4 5 2
  8
 
  much slower
 
     {.@(}.^:(6:{.)^:_@: +:) 2 1 3 2 4 5 2
  8
 
  But I prefer Raul's solution.
 
 
 
 
  On 17-11-13 03:38, Pascal Jasmin wrote:
 
  I spent some time describing the application.  You can also think of the
  application as search every web page on every ipv4 until the first
  interesting thing is found.  Maybe I care about a 2nd interesting thing,
  maybe I don't.  But I'd like to see the first before I ask for another,
 and
  the approach of finding them all and then returning the first is not
  practical.
 
  The explicit version I provided is not unworkable.  I was hoping that
  there is a version with {. and $:@:}.
 
 
  - Original Message -
  From: Raul Miller rauldmil...@gmail.com
  To: Programming forum programm...@jsoftware.com
  Cc:
  Sent: Saturday, November 16, 2013 8:56:03 PM
  Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
  definitions      possible?
 
      ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
  8
      ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
  4 2 6 4
 
  Now you might argue that this is not the same thing. But it is the same
  result.
 
  It's just faster

Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread R.E. Boss
Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?


R.E. Boss

(Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )

 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?
 
 2 conjunctions with monad only versions shown for simplicity
 
 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'
 
 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
end.
 )
 
    +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
    +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4
 
 both short circuit based on finding an exit condition.  I'd be surprised
that a
 tacit version is possible, but maybe through scan '/' and ^: ?
 
 I understand that the example is silly overkill, but the main application
is for
 repeatuntil is searching in many locations sorted by the likelihood of
finding it
 in a location.
 --
 For information about J forums see http://www.jsoftware.com/forums.htm

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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread Pascal Jasmin
I do.

^: either applies to y if v returns true, or returns y.

what I want is to stop application once v u y is true, and return the last u y.

The application is searching for a unique (or non existing) value across 
multiple locations, but once it is found, stop looking.

I tried something with {. to feed locations one at a time, and then $:@:}. as 
the keep looking instruction, but I may not understand $: well enough.




- Original Message -
From: R.E. Boss r.e.b...@planet.nl
To: programm...@jsoftware.com
Cc: 
Sent: Saturday, November 16, 2013 4:54:30 PM
Subject: Re: [Jprogramming] repeatuntil and repeat while tacit  definitions 
possible?

Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?


R.E. Boss

(Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )


 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?
 
 2 conjunctions with monad only versions shown for simplicity
 
 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'
 
 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
end.
 )
 
    +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
    +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4
 
 both short circuit based on finding an exit condition.  I'd be surprised
that a
 tacit version is possible, but maybe through scan '/' and ^: ?
 
 I understand that the example is silly overkill, but the main application
is for
 repeatuntil is searching in many locations sorted by the likelihood of
finding it
 in a location.
 --
 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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread km
The third shaded paragraph tells how to do a while loop with ^:

--Kip Murray

Sent from my iPad

 On Nov 16, 2013, at 4:34 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 
 I do.
 
 ^: either applies to y if v returns true, or returns y.
 
 what I want is to stop application once v u y is true, and return the last u 
 y.
 
 The application is searching for a unique (or non existing) value across 
 multiple locations, but once it is found, stop looking.
 
 I tried something with {. to feed locations one at a time, and then $:@:}. as 
 the keep looking instruction, but I may not understand $: well enough.
 
 
 
 
 - Original Message -
 From: R.E. Boss r.e.b...@planet.nl
 To: programm...@jsoftware.com
 Cc: 
 Sent: Saturday, November 16, 2013 4:54:30 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacitdefinitions 
possible?
 
 Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?
 
 
 R.E. Boss
 
 (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )
 
 
 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?
 
 2 conjunctions with monad only versions shown for simplicity
 
 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'
 
 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
 end.
 )
 
+:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
+:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4
 
 both short circuit based on finding an exit condition.  I'd be surprised
 that a
 tacit version is possible, but maybe through scan '/' and ^: ?
 
 I understand that the example is silly overkill, but the main application
 is for
 repeatuntil is searching in many locations sorted by the likelihood of
 finding it
 in a location.
 --
 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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread Pascal Jasmin
its not the same...

notice how both functions return fewer elements than are in y.

    +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
    +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4


I'd guess I need @. and $:


- Original Message -
From: km k...@math.uh.edu
To: programm...@jsoftware.com programm...@jsoftware.com
Cc: 
Sent: Saturday, November 16, 2013 6:06:06 PM
Subject: Re: [Jprogramming] repeatuntil and repeat whiletacit   
definitions possible?

The third shaded paragraph tells how to do a while loop with ^:

--Kip Murray

Sent from my iPad

 On Nov 16, 2013, at 4:34 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 
 I do.
 
 ^: either applies to y if v returns true, or returns y.
 
 what I want is to stop application once v u y is true, and return the last u 
 y.
 
 The application is searching for a unique (or non existing) value across 
 multiple locations, but once it is found, stop looking.
 
 I tried something with {. to feed locations one at a time, and then $:@:}. as 
 the keep looking instruction, but I may not understand $: well enough.
 
 
 
 
 - Original Message -
 From: R.E. Boss r.e.b...@planet.nl
 To: programm...@jsoftware.com
 Cc: 
 Sent: Saturday, November 16, 2013 4:54:30 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit    definitions 
    possible?
 
 Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?
 
 
 R.E. Boss
 
 (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )
 
 
 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?
 
 2 conjunctions with monad only versions shown for simplicity
 
 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'
 
 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
 end.
 )
 
    +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
    +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4
 
 both short circuit based on finding an exit condition.  I'd be surprised
 that a
 tacit version is possible, but maybe through scan '/' and ^: ?
 
 I understand that the example is silly overkill, but the main application
 is for
 repeatuntil is searching in many locations sorted by the likelihood of
 finding it
 in a location.
 --
 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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread Raul Miller
   ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
8
   ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
4 2 6 4

Now you might argue that this is not the same thing. But it is the same result.

It's just faster to compute this way. And, ok, I understand that speed
is not necessarily desirable. But I think in this case you might want
to just use a different language.

-- 
Raul


On Sat, Nov 16, 2013 at 6:51 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 its not the same...

 notice how both functions return fewer elements than are in y.

 +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
  8
 +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
  4 2 6 4


 I'd guess I need @. and $:


 - Original Message -
 From: km k...@math.uh.edu
 To: programm...@jsoftware.com programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 6:06:06 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat whiletacit   
 definitions possible?

 The third shaded paragraph tells how to do a while loop with ^:

 --Kip Murray

 Sent from my iPad

 On Nov 16, 2013, at 4:34 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:

 I do.

 ^: either applies to y if v returns true, or returns y.

 what I want is to stop application once v u y is true, and return the last u 
 y.

 The application is searching for a unique (or non existing) value across 
 multiple locations, but once it is found, stop looking.

 I tried something with {. to feed locations one at a time, and then $:@:}. 
 as the keep looking instruction, but I may not understand $: well enough.




 - Original Message -
 From: R.E. Boss r.e.b...@planet.nl
 To: programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 4:54:30 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitionspossible?

 Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?


 R.E. Boss

 (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )


 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?

 2 conjunctions with monad only versions shown for simplicity

 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'

 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
 end.
 )

+:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
+:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4

 both short circuit based on finding an exit condition.  I'd be surprised
 that a
 tacit version is possible, but maybe through scan '/' and ^: ?

 I understand that the example is silly overkill, but the main application
 is for
 repeatuntil is searching in many locations sorted by the likelihood of
 finding it
 in a location.
 --
 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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread Pascal Jasmin
I spent some time describing the application.  You can also think of the 
application as search every web page on every ipv4 until the first interesting 
thing is found.  Maybe I care about a 2nd interesting thing, maybe I don't.  
But I'd like to see the first before I ask for another, and the approach of 
finding them all and then returning the first is not practical.

The explicit version I provided is not unworkable.  I was hoping that there is 
a version with {. and $:@:}.


- Original Message -
From: Raul Miller rauldmil...@gmail.com
To: Programming forum programm...@jsoftware.com
Cc: 
Sent: Saturday, November 16, 2013 8:56:03 PM
Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions  
possible?

   ({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
8
   ({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
4 2 6 4

Now you might argue that this is not the same thing. But it is the same result.

It's just faster to compute this way. And, ok, I understand that speed
is not necessarily desirable. But I think in this case you might want
to just use a different language.

-- 
Raul


On Sat, Nov 16, 2013 at 6:51 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 its not the same...

 notice how both functions return fewer elements than are in y.

     +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
  8
     +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
  4 2 6 4


 I'd guess I need @. and $:


 - Original Message -
 From: km k...@math.uh.edu
 To: programm...@jsoftware.com programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 6:06:06 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while        tacit   
 definitions     possible?

 The third shaded paragraph tells how to do a while loop with ^:

 --Kip Murray

 Sent from my iPad

 On Nov 16, 2013, at 4:34 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:

 I do.

 ^: either applies to y if v returns true, or returns y.

 what I want is to stop application once v u y is true, and return the last u 
 y.

 The application is searching for a unique (or non existing) value across 
 multiple locations, but once it is found, stop looking.

 I tried something with {. to feed locations one at a time, and then $:@:}. 
 as the keep looking instruction, but I may not understand $: well enough.




 - Original Message -
 From: R.E. Boss r.e.b...@planet.nl
 To: programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 4:54:30 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit    
 definitions    possible?

 Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?


 R.E. Boss

 (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )


 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?

 2 conjunctions with monad only versions shown for simplicity

 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'

 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
 end.
 )

    +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
    +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4

 both short circuit based on finding an exit condition.  I'd be surprised
 that a
 tacit version is possible, but maybe through scan '/' and ^: ?

 I understand that the example is silly overkill, but the main application
 is for
 repeatuntil is searching in many locations sorted by the likelihood of
 finding it
 in a location.
 --
 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


Re: [Jprogramming] repeatuntil and repeat while tacit definitions possible?

2013-11-16 Thread Raul Miller
I don't see anything wrong with the explicit form if you are
constrained by external resources.

Tacit form is great for expressing computations but I'd just move on
when dealing with communications.

Thanks,

-- 
Raul


On Sat, Nov 16, 2013 at 9:38 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 I spent some time describing the application.  You can also think of the 
 application as search every web page on every ipv4 until the first 
 interesting thing is found.  Maybe I care about a 2nd interesting thing, 
 maybe I don't.  But I'd like to see the first before I ask for another, and 
 the approach of finding them all and then returning the first is not 
 practical.

 The explicit version I provided is not unworkable.  I was hoping that there 
 is a version with {. and $:@:}.


 - Original Message -
 From: Raul Miller rauldmil...@gmail.com
 To: Programming forum programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 8:56:03 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions
   possible?

({~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
 8
({.~ 1 i.~ 6  ]) +: 2 1 3 2 4 5 2
 4 2 6 4

 Now you might argue that this is not the same thing. But it is the same 
 result.

 It's just faster to compute this way. And, ok, I understand that speed
 is not necessarily desirable. But I think in this case you might want
 to just use a different language.

 --
 Raul


 On Sat, Nov 16, 2013 at 6:51 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:
 its not the same...

 notice how both functions return fewer elements than are in y.

 +:  repeatuntil (6  ]) 2 1 3 2 4 5 2
  8
 +:  repeatwhile (6  ]) 2 1 3 2 4 5 2
  4 2 6 4


 I'd guess I need @. and $:


 - Original Message -
 From: km k...@math.uh.edu
 To: programm...@jsoftware.com programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 6:06:06 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat whiletacit   
 definitions possible?

 The third shaded paragraph tells how to do a while loop with ^:

 --Kip Murray

 Sent from my iPad

 On Nov 16, 2013, at 4:34 PM, Pascal Jasmin godspiral2...@yahoo.ca wrote:

 I do.

 ^: either applies to y if v returns true, or returns y.

 what I want is to stop application once v u y is true, and return the last 
 u y.

 The application is searching for a unique (or non existing) value across 
 multiple locations, but once it is found, stop looking.

 I tried something with {. to feed locations one at a time, and then $:@:}. 
 as the keep looking instruction, but I may not understand $: well enough.




 - Original Message -
 From: R.E. Boss r.e.b...@planet.nl
 To: programm...@jsoftware.com
 Cc:
 Sent: Saturday, November 16, 2013 4:54:30 PM
 Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
 definitionspossible?

 Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?


 R.E. Boss

 (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )


 -Original Message-
 From: programming-boun...@forums.jsoftware.com [mailto:programming-
 boun...@forums.jsoftware.com] On Behalf Of Pascal Jasmin
 Sent: zaterdag 16 november 2013 21:32
 To: programm...@jsoftware.com
 Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
 possible?

 2 conjunctions with monad only versions shown for simplicity

 repeatuntil =: 2 : 'for_i. y do. if. v_ s =. u i do. s break. end. end.'

 repeatwhile =: 2 : 0
 out =. i.0
 for_i. y do. if. v_ s =. u i do. out break. else. out =. out , s  end.
 end.
 )

+:  repeatuntil (6  ]) 2 1 3 2 4 5 2
 8
+:  repeatwhile (6  ]) 2 1 3 2 4 5 2
 4 2 6 4

 both short circuit based on finding an exit condition.  I'd be surprised
 that a
 tacit version is possible, but maybe through scan '/' and ^: ?

 I understand that the example is silly overkill, but the main application
 is for
 repeatuntil is searching in many locations sorted by the likelihood of
 finding it
 in a location.
 --
 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