bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Short circuiting expressions like OR and AND


From: Juergen Sauermann
Subject: Re: [Bug-apl] Short circuiting expressions like OR and AND
Date: Sat, 17 Sep 2016 21:17:24 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hi Ala'a

the trick with ⎕EA is actually to return a value from a function only on success and no value
(instead of an empty value) if not.

'Z←bar B'  ⎕EA  'Z←foo B'    ⍝ ... ⎕EA 'Z←XYZ B' ...

If foo B returns no value then Z←
foo B fails and (only then) will bar B be performed.
As I said: "abuse ⎕EA".

I believe your function below can be simplified like this:

 words candidates word
  →(⍴words←known word)↓0
  →(⍴words←know edits1 word)↓0
  →(⍴words←know edits2 word)↓0
  words←⊂word
 
/// Jürgen


On 09/17/2016 08:02 PM, Ala'a Mohammad wrote:
Hi Jürgen,

Thanks for the pointer.

I understand that ⎕EA is a guard and so 'does not succeed' does not
include the 'empty set' or 'no result'. for example in Gnu APL
      '3' ⎕EA '0 0 0/ 1 2 3'

      '3' ⎕EA '0 1 0/ 1 2 3'
2

What I was thinking of is something that will return 3 in the first,
since ⍬≡0 0 0/ 1 2 3

Please correct me If I got something-or-all wrong.

The following is what I was trying to simplify
∇ words candidates word
  words ← known word
  (0<⍴words)/exit
  words ← know edits1 word
  (0<⍴words)/exit
  words ← know edits2 word
  (0<⍴words)/exit
  words ← ⊂word
exit:

Regards,

Ala'a



reply via email to

[Prev in Thread] Current Thread [Next in Thread]