Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:40:42+00:00 2026-06-03T16:40:42+00:00

Currently I’m trying to learn Clojure and I would like to write a function

  • 0

Currently I’m trying to learn Clojure and I would like to write a function that has a variable amount of parameters. This function should filter every input to check if it’s a string or not. If it does, every input of type string should be returned..

Clojure is hard for me and different way of thinking, but am I on the right direction here.. I can’t seem to solve it:

(defn returnString [& y]
(if (next y)
(filter (fn [x] (= (type x) "java.lang.String"))y)
(recur (next x))))

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:40:43+00:00Added an answer on June 3, 2026 at 4:40 pm

    There is a function called string? that returns true if the argument is a string, or false if not.

    => (string? "hi")
    true
    => (string? 100)
    false
    => (string? ["a" "b" "c"])
    false
    

    So with that in mind, your function would look like:

    (defn return-strings [& vals]
      (filter string? vals))
    

    The filter function will return a sequence (essentially a collection) of values, so there is no need worry about recursion (that is, using recur) in your custom function for this case.


    The anonymous function you use to determine what is a string is very close to being correct. If you take a look at the source for string? by entering (source string?) into your REPL, you’ll see:

    (fn [x] (instance? String x))
    

    Although, the approach you are taking would work as well. You just need to specify the String class instead of the string value you were giving. (Note, you can leave off java.lang because that package is automatically included just like it is in Java.)

    (fn [x] (= (type x) String))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a class that looks like this: public class MyClass : IMyClass
Currently, my ListViews look like this: How can I achieve that Windows 7 native
Currently I'm trying to write my first Python library and I've encountered the following
Currently I am debugging the signing of an Android app. And this would be
Currently, my MVC 3 app has a dependency on a static class that is
Currently I am doing it like this: CGRect frameRect = myUIImageView.frame; CGPoint rectPoint =
Currently the HashSet<T> constructor that allows you to define your equality comparison yourself is
Currently developing an application using the newest version of symfony, obtained through PEAR. This
Currently ASP.NET MVC's OutputCache attribute has a huge downfall. If you want to cache
Currently, I have something like: public partial class Form1 : Form { delegate void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.