#3 please add sequence generator

closed
nobody
None
5
2013-01-22
2009-10-10
No

Hi John,

gmsl is a nice thing. :-) Thanks.

What about adding a sequence function (doing something similar to /usr/bin/seq) to gmsl?
("seq" is already used for string equal, so I use "sequence")

e.g. $(call sequence,3,5) should return "3 4 5" (like $(shell seq 3 5))
so you can do for-loops and similar stuff:

$foreach i,$(call sequence,$(first),$(last)),do something with $i)

from SEQ(1):
seq [OPTION]... LAST
seq [OPTION]... FIRST LAST
seq [OPTION]... FIRST INCREMENT LAST
I think the one-argument form can be omitted, the two-argument would be the most important (if FIRST > LAST, return empty), the three-argument form is optional.

Andreas

Discussion

  • Eldar Abusalimov

    I agree, nice proposition!

    The possible implementation for the simplest case is:

    sequence = $(if $(call lt,$1,$2) \ ,$(call sequence_inc,$1,$2),$(call sequence_dec,$2,$1))
    sequence_inc = $1$(if $(call lt,$1,$2),$(call $0, $(call inc,$1),$2))
    sequence_dec = $(if $(call lt,$1,$2),$(call $0,$(call inc,$1) ,$2))$1

     
  • John Graham-Cumming

    OK. I will add this in GMSL 1.1.3

     
  • John Graham-Cumming

    • status: open --> accepted
    • milestone: --> Next_Release_(example)
     
  • John Graham-Cumming

    • status: accepted --> closed
     
  • John Graham-Cumming

    Added this functionality in what will be release 1.1.3

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks