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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:11:45+00:00 2026-05-27T23:11:45+00:00

The below snippets of code are part of an attempt at creating a function

  • 0

The below snippets of code are part of an attempt at creating a function generateUpTo which generates a list pAllSorted which depends on nmax and thus rmax.

nmax = rmax `div` 10

pass = rmax `elem` mot
fail = rmax `notElem` mot

generateUpTo rmax = check rmax
where 
         check pass = pAllSorted
         check fail = error "insert multiple of 10!"

However, when attempting to compile, the compiler gives a “Not in scope” error about rmax in (what is here) line 1,3 and 4.

(How) can I leave rmax undefined until using the generateUpTo function?

  • 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-27T23:11:46+00:00Added an answer on May 27, 2026 at 11:11 pm

    If you want to use rmax inside nmax, pass, and fail without passing it as an arguement, you’ll need to include it in the where block of generateUpTo. Otherwise, it’s literally, “not in scope”. Example:

    generateUpTo rmax = check rmax
        where 
             check pass = pAllSorted
             check fail = error "insert multiple of 10!"
             nmax = rmax `div` 10
             pass = rmax `elem` mot
             fail = rmax `notElem` mot
    

    If you want these functions to be used in multiple places, you could just accect rmax as an arguement:

    nmax rmax = rmax `div` 10
    pass rmax = rmax `elem` mot
    fail rmax = rmax `notElem` mot
    

    Note – it looks like you also have some problems with your definition of check… the pass and fail value there are just arguements of check, and not the functions you’ve defined above.

    Update

    to use nmax (the outside-the-where-block scope version), you’ll need to pass the value of rmax to it. Like so:

    nmax rmax  -- function application in Haskell is accomplished with a space,
               -- not parens, as in some other languages.
    

    Note, however, the name rmax in the definition of nmax is no longer significant. These functions are all exactly the same:

    nmax rmax = rmax `div` 10
    nmax a = a `div` 10
    nmax x = x `div` 10
    

    Likewise, you don’t need to call it with a value named rmax.

    nmax rmax
    nmax 10    -- this is the same, assuming rmax is 10
    nmax foo   -- this is the same, assuming foo has your 'rmax' value.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I am running either of the code snippets below for a list of
Given the below setup and code snippets, what reasons can you come up with
Which code snippet will give better performance? The below code segments were written in
had a two part question with regard to below contrived c++ code snippet :
Does anyone know what's wrong with the code below? The this->progressBar1->Value part worked by
What is the difference between the below code snippets? Won't both be using threadpool
I have the code snippet below in C++ which basically calculates the pi using
So, I have the code below which works fine when entered into Google's Rich
level: beginner Below snippet is part of code that counts letters in an array.
In the code snippet below, from my jQuery setup, I need to check if

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.