Skip to content

Instantly share code, notes, and snippets.

@stevemohapibanks
Created September 24, 2010 14:42
Show Gist options
  • Save stevemohapibanks/595497 to your computer and use it in GitHub Desktop.
Save stevemohapibanks/595497 to your computer and use it in GitHub Desktop.
(defn rpad-seq
[s n x]
(if (< (count s) n)
(seq (apply conj (vec s) (replicate (- n (count s)) x)))
s))
=> (rpad-seq (list "a" "b" "c") 10 "d")
("a" "b" "c" "d" "d" "d" "d" "d" "d" "d")
Thanks to Mr Purcell for the refactor below:
(defn rpad-seq [s n x]
(take n (concat s (repeat x))))
@purcell
Copy link

purcell commented Sep 24, 2010

or not at work, as the case may be!

@stevemohapibanks
Copy link
Author

Any programming language that has a function called lazy-cat is cool with me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment