Get a frame of lines from a table by filter

Started by lyl, April 20, 2019, 05:41:53 PM

Previous topic - Next topic

lyl

I have a table like this:
(setq lst '(("header1" "header2" "header3") ( "11" "12" "13") ("21" "22" "23") ("31" "32" "33") ("41" "42" "43" )))

I want to get some continueous lines e.g. from the first line to the third line by this:
(filter (and (>= $idx 1) (<= $idx 3)) lst)  ;; '(( "11" "12" "13") ("21" "22" "23") ("31" "32" "33") ) wanted.

But I find the function "filter" does not support "$idx".

So, is there a better way to achieve this?

Lutz

#1

> (slice lst 1 3)
(("11" "12" "13") ("21" "22" "23") ("31" "32" "33"))
>

http://www.newlisp.org/downloads/newlisp_manual.html#slice">http://www.newlisp.org/downloads/newlis ... html#slice">http://www.newlisp.org/downloads/newlisp_manual.html#slice



Or shorter:

> (1 3 lst)
(("11" "12" "13") ("21" "22" "23") ("31" "32" "33"))

See here:

http://www.newlisp.org/downloads/newlisp_manual.html#implicit_rest_slice">http://www.newlisp.org/downloads/newlis ... rest_slice">http://www.newlisp.org/downloads/newlisp_manual.html#implicit_rest_slice