[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Axiom-developer] any?, member?, ...

**From**: |
Martin Rubey |

**Subject**: |
[Axiom-developer] any?, member?, ... |

**Date**: |
Wed, 23 Jun 2004 16:00:12 +0000 |

I noticed that these function evaluate the predicate for all elements of the
argument list, which I find rather strange. For example:
(2) -> any?(i+->(output(i);(i=1)::Boolean),[1,2,3])
1
2
3
(2) true
Type: Boolean
Wouldn't it be sensible to define these functions so that they exit when the
result is determined, i.e., instead of
any?(f, c) == _or/[f x for x in parts c]
every?(f, c) == _and/[f x for x in parts c]
do
any?(f, c) ==
for x in parts c repeat
if f x then return true
false
every?(f, c) ==
for x in parts c repeat
if not f x then return false
true
It seems that for TREE, some shortcircuiting is done:
any?(fn, t) == ---bug fixed
t case empty => false
fn value t or "or"/[any?(fn, c) for c in children t]
every?(fn, t) ==
t case empty => true
fn value t and "and"/[every?(fn, c) for c in children t]
Martin

**[Axiom-developer] any?, member?, ...**,
*Martin Rubey* **<=**
**Re: [Axiom-developer] any?, member?, ...**, *William Sit*, `2004/06/23`
**Re: [Axiom-developer] any?, member?, ...**, *Martin Rubey*, `2004/06/23`
**Re: [Axiom-developer] any?, member?, ...**, *William Sit*, `2004/06/23`
**Re: [Axiom-developer] Patch 3148, was: any?, member?, ...**, *Martin Rubey*, `2004/06/23`
**Re: [Axiom-developer] Patch 3148, was: any?, member?, ...**, *William Sit*, `2004/06/23`
**Re: [Axiom-developer] history, was: Patch 3148, was: any?, member?, ...**, *Martin Rubey*, `2004/06/23`