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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:08:11+00:00 2026-06-03T17:08:11+00:00

The first of the following two functions, fn-apply-cmp-vals, returns a partial function that is

  • 0

The first of the following two functions, fn-apply-cmp-vals, returns a partial function that is used in the second function, apply-cmp-vals.

What is the correct syntax to embed fn-apply-cmp-vals as an anonymous function in apply-cmp-vals?

(defn fn-apply-cmp-vals
    [fn cmp-sos cmp-idx]
    (partial fn cmp-sos cmp-idx))

(defn apply-cmp-vals
    [cmp-vec cmp-vals cmp-vec-idx]
    (let [fn-cmp (fn-apply-cmp-vals ret-non-match-rows cmp-vec cmp-vec-idx)]
        (map #(fn-cmp %1) cmp-vals)))

Specifically, I want to replace fn-apply-cmp-vals ret-non-match-rows cmp-vec cmp-vec-idx) with an anonymous function instead of a function call.
Thank You.

  • 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-03T17:08:12+00:00Added an answer on June 3, 2026 at 5:08 pm

    Lets take a look at this, in detail, one step at a time.

    Your goal is to inline fn-apply-cmp-vals as an anonymous function in apply-cmp-vals. So lets do that first. Here is what your function looks like with no other changes:

    (defn apply-cmp-vals
      [cmp-vec cmp-vals cmp-vec-idx]
      (let [fn-cmp ((fn [f cmp-sos cmp-idx] (partial f cmp-sos cmp-idx))
                      ret-non-match-rows cmp-vec cmp-vec-idx)]
        (map #(fn-cmp %1) cmp-vals)))
    

    This accomplishes your goal, but there is room for improvement. Since your function simply calls partial with the given arguments, lets replace the anonymous function with a direct call to partial with the correct arguments. This works because partial returns a partially applied function.

    (defn apply-cmp-vals
      [cmp-vec cmp-vals cmp-vec-idx]
      (let [fn-cmp (partial ret-non-match-rows cmp-vec cmp-vec-idx)]
        (map #(fn-cmp %1) cmp-vals)))
    

    Now, lets look where fn-cmp is used. It is being called in its own anonymous function with a single argument. Since your partial function satisfies this requirement, you could instead just pass fn-cmp into the map function directly.

    (defn apply-cmp-vals
      [cmp-vec cmp-vals cmp-vec-idx]
      (let [fn-cmp (partial ret-non-match-rows cmp-vec cmp-vec-idx)]
        (map fn-cmp cmp-vals)))
    

    Finally, if you desire, you can completely remove the let form:

    (defn apply-cmp-vals
      [cmp-vec cmp-vals cmp-vec-idx]
      (map (partial ret-non-match-rows cmp-vec cmp-vec-idx) cmp-vals)))
    

    So it turns out you didn’t need an anonymous function at all!

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

Sidebar

Related Questions

Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
Suppose you have a Django view that has two functions: The first function renders
Suppose I have two arrays like the following: $arr2 = array(array(first, second), array(third, fourth));
Are the following two statements the same? Users user = db.Users.First(u => (u.Username ==
I have the two following text files: First one: chr10 1000 1001 DEL 2.4807
I have two CSS rules following each other: .some td:first-child:before { content:url('path/to/image.png') ; }
I have the following two functions: public class MyClass { public void Save<TObject>(TObject object)
Say I have the following two functions: 1 int * foo() { int b=8;
I have two functions declared as following, using extern C aming to avoid name
I have the following two functions. One checks for a class and if none

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.