to rs.module
    ;; regular sequences
end
;------------------------------------------------- sequences-----------------------------------------------------------
to rs.iseq :from :to  
    ;; Returns a list of integers.

    ;; Parameters
    ;; **from**: lower bound (included)
    ;; **to**: upper bound (included)

    ;; Examples
    ;;; show rs.iseq 3 7  

	output iseq :from  :to

end

to rs.rseq :from :to :count
    ;; Returns  outputs a list of equally spaced rational numbers.

    ;; Parameters
    ;; **from**: lower bound (included)
    ;; **to**: upper bound (included)
    ;; **count*: number of rational numbers numbers

    ;; Examples
    ;;; show rs.rseq 3 5 5

	output rseq :from :to :count

end

;------------------------------------------------- random sequences-----------------------------------------------------------

to rs.rand :a :b :times
    ;; Returns a list of random numbers

    ;; Parameters
    ;; **a**: lower bound (included)
    ;; **b**: upper bound (included)
    ;; **times**: number random numbers

    ;; Examples
    ;;; show rs.rand 1 100 20 

	if equalp :times 0 [output []]
	output se (random :a :b) rs.rand :a :b difference :times 1
end

to rs.pick :list :times
    ;; Returns a list of random element picked from a list

    ;; Parameters
    ;; **a**: lower bound (included)
    ;; **b**: upper bound (included)
    ;; **times**: number random numbers

    ;; Examples
    ;;;  show rs.pick ["f  "m] 20

	if equalp :times 0 [output []]
	output se (pick :list) (rs.pick :list difference :times 1)
end
;------------------------------------------------- repetitions-----------------------------------------------------------

to rs.rep :list  [each 1] [times 1]
    ;; Replicates the values in a list

    ;; Parameters
    ;; **list**: list of element to be replicated
    ;; **each**: repeats each list element 'each' times
    ;; **times**: repeats the list 'times' times

    ;; Returns
    ;; A list.

    ;; Examples
	;;; show (rs.rep (list "a "b) 1 1)
	;;; show (rs.rep (list "a "b) 2 1)
	;;; show (rs.rep (list "a "b) 1 2)
	;;; show (rs.rep (list "a "b) 2 2)

    if or lessp :each 1 lessp :times 1 [output "|Inputs should be positive integers|]
    if and equalp :each 1 equalp :times 1 [output :list]
    if and greaterp :each 1 equalp :times 1 [output (rs.repeach :list :each)]
    if and equalp :each 1 greaterp :times 1 [output (rs.reptimes :list :times)]
    if and greaterp :each 1 greaterp :times 1 [output (rs.reptimes (rs.repeach :list :each) :times)]
end

to rs.repeach :list  [each 1]
    if emptyp :list [output []]
    output se rs.repeach.helper first :list :each (rs.repeach  butfirst :list :each)
end

to rs.repeach.helper :elem :each
    if equalp :each 0 [output []]
    output se :elem rs.repeach.helper :elem difference :each 1
end

to rs.reptimes :list  [times 1]
    if equalp :times 0 [output []]
    output se :list (rs.reptimes  :list difference :times 1)
end

