1. Re: Some more routines...

I've placed these in my stddefs.e file (the archive isn't
  updated yet) - you can (obviously) place them anywhere you
  find useful.

  global function all(object o)
    if atom(o) then
      return o
    end if
    for i = 1 to length(o) do
      if not o[i] then
        return 0
      end if
    end for
    return 1
  end function

  global function any(object o)
    if atom(o) then
      return o
    end if
    for i = 1 to length(o) do
      if o[i] then
        return 1
      end if
    end for
    return 0
  end function
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  trivial usage examples:

  sequence a
  a = {0,15,0,0,21,0,3}

  if any(a=15) then
    puts(1,"At least one element of a is fifteen\n")
  end if

  a = {5,4,5,7,5,7,9,21,78}

  if all(a>3) then
    puts(1,"All elements of a are greater than three\n")
  end if

 =========================================================================
Jeff Zeitlin                                      jeff.zeitlin at execnet.com
---
 ~ OLXWin 1.00b ~ If we took the bones out, it wouldn't be crunchy!

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu