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 67
67
# (let cool-stuff [1 2 3 4 5 6 7 8 9])
68
68
# (print (list:drop cool-stuff 4)) # [5 6 7 8 9]
69
69
# =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
+ })))
80
85
81
86
# @brief Drop the first elements of a list, while they match a given predicate
82
87
# @param _L the list to work on
You can’t perform that action at this time.
0 commit comments