Is there a compact way to reference the Nth result in the set of results
produced?

For example, suppose that I want to obtain the third result produced by
the expression ("a"|"b"|"c"|"d").  Thinking in my stone-age procedural way,
I would write:

procedure main()
  i := 0
  every s := ("a"|"b"|"c"|"d") do {
    write ("s = "||s)
    i +:= 1
    if i = 3 then {
      write ("i = "||i)
      write(s)
      break
    }
  }
end

I suppose that I could do this with a co-expression:

procedure main()
  E := create ("a"|"b"|"c"|"d")
  i := 0
  while s := ! @E do {
    write ("s = "||s)
    i +:= 1
    if i = 3 then {
      write ("i = "||i)
      write(s)
      break
    }
  }
end

but I don't think that immediately gives me much benefit.

What I'm hoping for is a compact syntax, similar to one of the following
examples except that it would actually work!
  ("a"|"b"|"c"|"d")[3]
  3("a"|"b"|"c"|"d")

The most compact idiom I have come up with is:
every s := ("a"|"b"|"c"|"d")\3 ; write (s)
Any suggestions? 
Is there an idiomatic way to get rid of the variable s for example?

_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to