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

  • Home
  • SEARCH
  • 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 6611587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:59:21+00:00 2026-05-25T19:59:21+00:00

I want to create a closure (function generator) to raise a number to a

  • 0

I want to create a closure (function generator) to raise a number to a power, without using a specific Clojure library to accomplish this task. Right now, I can do this with loop .. recur.

(defn exp1
 [in-num in-exp-multi]
 (loop [num in-num exp-multi in-exp-multi]
    (if (> exp-multi 1)
        (recur (* num in-num) (- exp-multi 1))
        num)))

I have tried using partial to raise the power, but am still stuck on the construct needed to repeat multiplying a number by itself some number of times. So, I am looking for an example of generating a function and applying it x number of times.

Edit:

The example was simply to solve a problem using loop .. recur. My desire is to solve this with a closure.

  • 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-05-25T19:59:21+00:00Added an answer on May 25, 2026 at 7:59 pm

    I can’t tell from your question precisely what you’re asking for, but maybe this?

    (defn powers-of [exponent]
      (iterate #(* % exponent) 1))
    
    (defn nth-power-of [exponent]
      (partial nth (powers-of exponent)))
    
    ((nth-power-of 5) 2) ;; returns 25
    

    I think iterate is what you’re looking for based on your description; it creates a lazy seq of the function applied over and over to the seed.

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

Sidebar

Related Questions

I want to create a Java application bundle for Mac without using Mac. According
I want to create n number of EditText objects ...so I am using LayoutInflater
I want to create a function that performs a function passed by parameter on
I'm using Google closure to create a simple interactive graphic in HTML/JS to be
I want create a function that verify if the numbers of a list fall
Let's say I want to build a large clojure library with several components. As
Just about everyone has ran into this specific issue: function addLinks () { for
I want to create a function that receives 2 arguments and returns a function
Using clojure and clojure-sql with postgresql. I am trying to make a bootstrap function,
I want create a drop shadow around the canvas component in flex. Technically speaking

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.