I just starting learning functional programming and need help with something that I would think is really easy, but can't figure out (been a long day).
Basically I have multiple lists (each with ints) within a bigger list. I want to add an element to each list. What I have so far, but can't finish off...
(define (number-adder lstInlst x)
(map append x somehow??? lstInlst))
Any help is appreciated!
(map (lambda (lst)
(cons x lst))
list-of-lists)
Since you're using Racket, you can use curry
for something even shorter:
(map (curry cons x) list-of-lists)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.