|
Pages: [1]
|
 |
|
Author
|
Topic: negative skip + variable (Read 395 times)
|
|
pepiporn
|
>> a == ["hugo" "biene" "foo" "bar" "red red wine" "reggae music"] >> x == 2 >> skip a x == ["foo" "bar" "red red wine" "reggae music"] >> skip tail a -x ** Script Error: -x has no value ** Near: skip tail a -x >> skip tail a -2 == ["red red wine" "reggae music"]
hope you get what i want. skip from the end of a series with a variable length ( to get last 2, or last 5 or last 10, or ... ) ... at this occasion: how can i get the last 3 without the very last item? ( would be for that example: [ "foo" "bar" "red red wine" ] )
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
You just need a space between "-" and "x". (Without, "-x" is a single word.) >> skip tail a (- x) == ["red red wine" "reggae music"] >> skip tail a negate x == ["red red wine" "reggae music"] >> skip tail a x * -1 == ["red red wine" "reggae music"]
Also, for those used to BASIC (this is something that gets asked very often): >> left: func [series number] [copy/part series number] >> right: func [series number] [copy skip tail series negate number] >> mid: func [series start number] [copy/part at series start number] >> left a 3 == ["hugo" "biene" "foo"] >> right a 3 == ["bar" "red red wine" "reggae music"] >> mid a 3 3 == ["foo" "bar" "red red wine"] >> mid tail a -4 3 == ["foo" "bar" "red red wine"]
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |