/tutorial/agent/example5.e

http://github.com/tybor/Liberty · Specman e · 33 lines · 24 code · 4 blank · 5 comment · 0 complexity · d48b53e6096b67b54a6cba7c5713e2d2 MD5 · raw file

  1. class EXAMPLE5
  2. --
  3. -- There is also a `for_all' routine in COLLECTION (i.e. ARRAY,
  4. -- FAST_ARRAY, LINKED_LIST, TWO_WAY_LINKED_LIST).
  5. -- You can watch the result using sedb, the Liberty Eiffel DeBugger.
  6. --
  7. create {ANY}
  8. make
  9. feature {ANY}
  10. make
  11. local
  12. my_array: ARRAY[INTEGER]; bool: BOOLEAN
  13. do
  14. my_array := {ARRAY[INTEGER] 1, << 2, 3, 4 >> }
  15. bool := my_array.for_all(agent greater_than(?, 1))
  16. sedb_breakpoint
  17. bool := my_array.for_all(agent greater_than(1, ?))
  18. sedb_breakpoint
  19. bool := my_array.exists(agent greater_than(4, ?))
  20. sedb_breakpoint
  21. bool := my_array.exists(agent greater_than(?, 4))
  22. sedb_breakpoint
  23. end
  24. feature {}
  25. greater_than (item, value: INTEGER): BOOLEAN
  26. do
  27. Result := item > value
  28. end
  29. end -- class EXAMPLE5