seq( from m .. n, step )

Messages in english

compsystems
Messages : 539
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

seq( from m .. n, step )

Hello BP

seq( 0 .. 4, 1.9 ) [enter] ( 0, 1.9, 3.8 )

but

seq( 0 .. 4, 2 ) [enter] [ 0 .. 4, 0 .. 4 ]

Since there are two arguments, a sequence must return and not a list

[ 0 .. 4, 0 .. 4 ] -> ( 0 .. 4, 0 .. 4 )

eval( seq( 0 .. 4, 2 ) ) -> [0 .. 4,0 .. 4]

now the output to be useful should be

seq( 0 .. 4, 2 ) -> ( seq(0 .. 4), seq(0 .. 4) )
eval( seq( 0 .. 4, 2 ) ) -> 0,1,2,3,4,0,1,2,3,4

compsystems
Messages : 539
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: seq( from m .. n, step )

Edit: Although more useful is that if the first argument contains the operator .. do the following seq( from m .. n, step )

seq( 0 .. 4, 2 ) -> (0,2,4)

compsystems
Messages : 539
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: seq( from m .. n, step )

// Increase in one unit

seq1 := ( 1, 2, 3, 4 ) [enter] ( 1, 2, 3, 4 )
seq1a := seq( 1 .. 4 ) [enter] ( 1, 2, 3, 4 )
seq1b := seq( 0 .. 4 ) [enter] ( 0, 1, 2, 3, 4 )
seq1c := seq( -2 .. 4 ) [enter] ( -2, -1, 0, 1 , 2, 3, 4 )
seq1d := seq( 0.1 .. 3.8 ) [enter] ( 0.1, 1.1, 2.1, 3.1 )
seq1e := seq( -2.1 .. 1 )[enter] ( -2.1, -1.1, -0.1, 0.9 )

// Increase in a specific value

seq2 := seq( -2 .. 4, 0.8 ) [enter] ( -2, -1.2, -0.4, 0.4, 1.2, 2.0, 2.8, 3.6 )
seq2a := seq( -2 .. 4, 2 ) [enter] [ (-2 .. 4), (-2 .. 4) ] // /!\
seq2b :=seq( 0.3 .. 2, 0.4)[enter] ( 0.3, 0.7, 1.1, 1.5, 1.9 )

// Decrease in one unit
seq3 := seq( 11 .. 4 ) [enter] ( 11, 10, 9, 8, 7, 6, 5, 4 )
seq3a := seq( -5 .. -8 )[enter] ( -5, -6, -7, -8 )

// Decrease in a specific value
seq4 := seq( 11 .. 4, 2.5 )[enter] ( 11, 8.5, 6.0 )
seq4a := seq( 11 .. 4, 2 )[enter] [ (11 .. 4), (11 .. 4) ]. // /!\

Of the previous values only in the following two cases does not increase or decrease by a specific value

seq2a := seq( -2 .. 4, 2 ) [enter] [ (-2 .. 4), (-2 .. 4) ]
seq4a := seq( 11 .. 4, 2 )[enter] [ (11 .. 4), (11 .. 4) ]

propose an alternative solution, if the second argument is an integer with a dot not repeat the sequence of the first argument

seq2a := seq( -2 .. 4, 2.0 ) [enter] ( -2, 0, 2, 4 )
seq4a := seq( 11 .. 4, 2.0 )[enter] ( 11, 9, 7, 5, 3 )