lisp - What Racket function can I use to insert a value into an arbitrary position within a list? -


i know trivial implement, want racket live it's "batteries included" promise. looking function works this:

> (define (between lst item spot)     (append (take lst spot)             (cons item (drop lst spot)))) > (between '(1 3) 2 1) '(1 2 3) 

does racket include such builtin?

here implementation based on stephen chang's comment (i swapped argument order little , renamed function too):

(define (insert-at lst pos x)   (define-values (before after) (split-at lst pos))   (append before (cons x after))) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -