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 8440243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:14:16+00:00 2026-06-10T08:14:16+00:00

I have this Clojure code: (defn apply-all-to-arg [& s] (let [arg (first s) exprs

  • 0

I have this Clojure code:

(defn apply-all-to-arg [& s]
    (let [arg (first s)
          exprs (rest s)]
        (for [condition exprs] (condition arg))))

(defn true-to-all? [& s]
    (every? true? (apply-all-to-arg s)))

This is test code:

(apply-all-to-arg 2 integer? odd? even?)

=> (true false true)

(every? true? (apply-all-to-arg 2 integer? odd? even?)

=> false

(true-to-all? 2 integer? odd? even?)

=> true

My question is:
Why does the function true-to-all? return true (it must have returned false instead)

  • 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-10T08:14:18+00:00Added an answer on June 10, 2026 at 8:14 am

    true-to-all? calls apply-all-to-arg with the single argument s. So you’re not calling (every? true? (apply-all-to-arg 2 integer? odd? even?), but rather:

    (every? true? (apply-all-to-arg (list 2 integer? odd? even?))
    

    So in apply-all-to-arg the value of arg will be that list and the value of exprs will be the empty list. Since every? will be true for the empty list no matter what the condition is, you’ll get back true.

    To fix this you can either change apply-all-to-arg, so that it accepts a list instead of a variable number of arguments, or you can change true-to-all?, so that it passes the contents of s as multiple arguments rather than a single list (by using apply).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using clojure and hiccup (with noir) and I have this code: (defn
So I currently have this code: (ns contact-form.core (:gen-class)) (def foo Hello World!) (defn
When I paste this code into a REPL, it works fine: (use 'clojure.contrib.seq-utils) (defn-
i have this youtube url http://www.youtube.com/watch?v=9N51Etoikfw&feature=youtube_gdata i need to remove the feature parameter and
I would like to embed Clojure code into Java. This site was helpful in
Is there a simpler way to write this code in Clojure : (def queue
I have some Clojure code that seems maddeningly simple and yet is throwing an
I have a Clojure service that I'm exposing via REST. I have a page
I have the following Clojure code to calculate a number with a certain factorable
Suppose you have the following code: (ns foo) (defmacro defproject [project-name version & args]

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.