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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:04:31+00:00 2026-06-14T16:04:31+00:00

I need to make a function powers that takes a number n and returns

  • 0

I need to make a function “powers” that takes a number n and returns the infinite list of that number to the power of every number e.g.

powers 2 = 2,4,8,16,32......

I need to do this using very specific subset of the language where my only available built in functions are: div, mod, even, odd, head, tail, not, null, length, reverse, elem, map, filter, foldr, sum, product, take, drop, takewhile, dropWhile, zipWith and from.

the subset also has no ^ operator.

there are some further important constraints:

  • the code must not exceed 1 line of more than 80 characters
  • no “helper functions” allowed, i.e i cannot write another function to use within this definition.

So far my thinking is along these lines:

powers = \n -> map (\x -> "some function to get n to the power of x") (from 1)

but i cant figure out how to get the function to do this without a helper function.

for example if i was to use a function inflist that returned an infinite list of the number x then i could just do the following.

powers = \n -> map (\x -> product(take x (inflist n))) (from 1)

but i cant do this or anything like it because i couldn’t use that function.

Sorry if the notation is a different to normal haskell, its a very strict core haskell subset that uses this notation.

  • 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-14T16:04:32+00:00Added an answer on June 14, 2026 at 4:04 pm

    This is a recursion question.

    powers n = n : map (* n) (powers n)
    

    (Are you allowed to use :?)

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

Sidebar

Related Questions

I need to make a stored procedure or function that returns a set of
I need to make this function work everywhere, except IE6-7 $(function(){ window.scrollTo(0,300); }) Please
I need to make a Function that receives a Session Key and a Session
I need to make a synonym search function, using MySQL. Here is the tables
I have two Ajax calls. I need to make sure that a JS function
Need to make a function that would open a popout with a div inheriting
I am having a problem. I need to make a function called replaceText that
I need to make a function that works on it is won thread to
I have the following problem: I need to make a function which takes two
I need to make a function that can kill all processes owned by user

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.