#112
Sequs Horribilis
 

Difficulty:Medium
Topics:seqs


Create a function which takes an integer and a nested collection of integers as arguments. Analyze the elements of the input collection and return a sequence which maintains the nested structure, and which includes all elements starting from the head whose sum is less than or equal to the input integer.
test not run
(=  (__ 10 [1 2 [3 [4 5] 6] 7])    '(1 2 (3 (4))))
test not run
(=  (__ 30 [1 2 [3 [4 [5 [6 [7 8]] 9]] 10] 11])    '(1 2 (3 (4 (5 (6 (7)))))))
test not run
(=  (__ 9 (range))    '(0 1 2 3))
test not run
(=  (__ 1 [[[[[1]]]]])    '(((((1))))))
test not run
(=  (__ 0 [1 2 [3 [4 5] 6] 7])    '())
test not run
(=  (__ 0 [0 0 [0 [0]]])    '(0 0 (0 (0))))
test not run
(=  (__ 1 [-10 [1 [2 3 [4 5 [6 7 [8]]]]]])
                        '(-10 (1 (2 3 (4)))))


Code which fills in the blank: