I have a problem with generator.
Sometimes I write generator's output in one line, like
####################
# write output of generator
# 1,2,..,10 -> "1 2 3 .. 10"
# gentest1.icn

procedure main()
  write(&version)
  /s := " "
  n := 0
  every ss := seq() \10 do {
    if n > 0 then writes(s,ss)
             else writes(ss)
    n +:= 1
  }
  write()
end

gentest1 writes
Icon Version 9.3.2.  July 1, 1999
1 2 3 4 5 6 7 8 9 10

Then I try to make a procedure "gen_out" to write generator's output.
####################
# write output of generator
# 1,2,..,10 -> "1 2 3 .. 10" ?
# gentest2.icn

procedure main()
  write(&version)
  gen_out(seq() \10)
end

procedure gen_out(gen,s)
  /s := " "
  n := 0
  every ss := gen do {
    if n > 0 then writes(s,ss)
             else writes(ss)
    n +:= 1
  }
  write()
end

But gentest2 writes
Icon Version 9.3.2.  July 1, 1999
1
2
3
4
5
6
7
8
9
10

I cannot understand the behaviour of "gen_out".
Why "gen_out" does not work as I expect ?
How I change "gen_out" to write generator's output in one line ?

Thanks,
Hiroshi Shinohara


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to