• Skip to primary navigation
  • Skip to content
  • Skip to footer
Clojure Diary Clojure Diary
  • Search
  • Book
  • Code
  • Videos
  • Donate

    Porting single argument function to accept multiple arguments

    less than 1 minute read

    Notes

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    ;; porting_single_argument_function_to_accept_multiple_arguments.clj
    
    (defn say-hi
      ([name] (str "Hi " name))
      ([name & many-names] (map say-hi (conj many-names name))))
    
    (say-hi "Karthik")
    
    (map say-hi ["Karthik" "Mathew" "Orangutaan"])
    
    (say-hi "Karthik" "Mathew" "Orangutaan")
    

    Updated: June 6, 2023

    Twitter Facebook LinkedIn
    Previous Next

    You May Also Enjoy

    Creating code on the fly using Clojure eval

    less than 1 minute read

    Mount - Clojure State Management

    less than 1 minute read

    Commenting, i.e. adding docstrings to multimethods in Clojure

    less than 1 minute read

    Rant about strings. About comment, and work around to comment multimethods

    1 minute read

    • Feed
    © 2025 Clojure Diary. Powered by Jekyll & Minimal Mistakes.