I feel similarly: always use a built-in if there is one, even for something as simple as this. I couldn't find one either, and my solution is basically the same as Benny's, but there's no particular need to (let) the count, and once that's removed it's so short it almost doesn't merit a defn anymore:
(let [a '(1 2 3 4 5 6 7 8 9 10) b '(54 666 23)] (concat b (drop (count b) a))) => (54 666 23 4 5 6 7 8 9 10) On Dec 18, 2:32 pm, Glen Rubin <rubing...@gmail.com> wrote: > ok that's looks very succinct, I will use it. Just figured I would > ask if it exists, b/c always prefer to use a built-in and it sounded > basic enough to be. thanks! > > On Dec 18, 5:15 pm, Benny Tsai <benny.t...@gmail.com> wrote: > > > I didn't see a built-in fn for this, and couldn't restrain myself from > > trying to write one: > > > (defn replace-first-n [xs ys] > > (let [n (count ys)] > > (concat ys (drop n xs)))) > > > On Dec 18, 2:38 pm, Glen Rubin <rubing...@gmail.com> wrote: > > > > I am looking for a fn that does the following. Let's say i have > > > sequences A & B > > > > A: '(1 2 3 4 5 6 7 8 9 10) > > > > B '(54 666 23) > > > > I want to replace A's first items with B's, so that I get: > > > > '(54 666 23 4 5 6 7 8 9 10) > > > > Is there a fn to do this? Otherwise, I will write one. Thanks! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en