Louis, Steve, Thank you for your kind explanations. Steve >The problem is that gen_out() itself knows nothing about it's Steve >calling environment and so doesn't know that it's got a generator Steve >producing values for its first parameter ...
I see! I must put "procedure" for the argument of gen_out. #################### # write output of generator # 1,2,..,10 -> "1 2 3 .. 10" # gentest3.icn procedure main() write(g2s(seq,,10)) end procedure g2s(gproc,Larg,n_limit,s) /s := " " # delimiter /Larg := [] # argument of gproc s1 := "" every s2 := if /n_limit then gproc ! Larg else gproc ! Larg \n_limit do s1 ||:= (s2 || s) return s1[1:-*s] end I have another question with generator. A few weeks ago I wrote a program to generate column numbers like MS Excel (A,B,..,Z,AA,AB,..IV). It worked as I expected and made me think "a generator can be put as a argument of a procedure". #################### # generator of column numbers like MS Excel (A,B,..X,AA,AB,..,IV) #################### # gentest4.icn procedure main() every s := linegw(right(msperm(&ucase,1 to 2) \256,2) | &null) do write(s) end #################### # permutation generator #################### # arg [1]: s string : seed # [2]: m integer : size of string # value: string # Usage: every ss := msperm(s,m) do ... # ("abc",2) -> "aa","ab","ac","ba","bb","bc","ca","cb","cc" procedure msperm(s,m) /m := *s if m = 0 then return "" suspend !s || msperm(s,m-1) end #################### # words to one line generator #################### # arg [1]: string (word generator stopper: &null) # [2]: integer (screen or paper width) # [3]: string (delimiter) # value : string (line) # Usage : every s := linegw(gen() | &null,n_limit,s_delim) do .. procedure linegw(s_gen,n_limit,s_delim) static s_buf initial s_buf := "" /n_limit := 79 /s_delim := " " if \s_gen then { if (*s_buf + *s_delim + *s_gen) > n_limit then { if *s_buf > 0 then { suspend s_buf do s_buf := "" } } s_buf ||:= if *s_buf = 0 then s_gen else s_delim || s_gen } else if *s_buf > 0 then suspend s_buf do s_buf := "" end output of gentest4 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA AB AC AD AE AF AG AH AI AJ AK AL AM AN AO AP AQ AR AS AT AU AV AW AX AY AZ BA BB BC BD BE BF BG BH BI BJ BK BL BM BN BO BP BQ BR BS BT BU BV BW BX BY BZ CA CB CC CD CE CF CG CH CI CJ CK CL CM CN CO CP CQ CR CS CT CU CV CW CX CY CZ DA DB DC DD DE DF DG DH DI DJ DK DL DM DN DO DP DQ DR DS DT DU DV DW DX DY DZ EA EB EC ED EE EF EG EH EI EJ EK EL EM EN EO EP EQ ER ES ET EU EV EW EX EY EZ FA FB FC FD FE FF FG FH FI FJ FK FL FM FN FO FP FQ FR FS FT FU FV FW FX FY FZ GA GB GC GD GE GF GG GH GI GJ GK GL GM GN GO GP GQ GR GS GT GU GV GW GX GY GZ HA HB HC HD HE HF HG HH HI HJ HK HL HM HN HO HP HQ HR HS HT HU HV HW HX HY HZ IA IB IC ID IE IF IG IH II IJ IK IL IM IN IO IP IQ IR IS IT IU IV every s := linegw(right(msperm(&ucase,1 to 2) \256,2) | &null) do write(s) This looks like msperm has a generator 1 to 2 as a argument right has a generator msperm as a argument linegw has a generator right(generator) | &null as a argument How this program works as I expect? Thanks, Hiroshi Shinohara ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Unicon-group mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/unicon-group