File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change 6767# (let cool-stuff [1 2 3 4 5 6 7 8 9])
6868# (print (list:drop cool-stuff 4)) # [5 6 7 8 9]
6969# =end
70- # @author https://github.com/rstefanic
71- (let list:drop (fun (_L _n) {
72- (mut _index (math:max 0 _n))
73- (mut _output [])
74- (while (< _index (len _L)) {
75- (set _output (append _output (@ _L _index)))
76- (set _index (+ 1 _index))
77- })
78- _output
79- }))
70+ # @author https://github.com/rstefanic, https://github.com/SuperFola
71+ (let list:drop (fun (_L _n)
72+ (if (< _n (/ (len _L) 2))
73+ (if (> _n 0)
74+ (list:drop (tail _L) (- _n 1))
75+ _L)
76+ {
77+ (mut _index (math:max 0 _n))
78+ (mut _output [])
79+ (while (< _index (len _L)) {
80+ (set _output (append _output (@ _L _index)))
81+ (set _index (+ 1 _index))
82+ })
83+ _output
84+ })))
8085
8186# @brief Drop the first elements of a list, while they match a given predicate
8287# @param _L the list to work on
You can’t perform that action at this time.
0 commit comments