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?
If you want to use
rmaxinsidenmax,pass, andfailwithout passing it as an arguement, you’ll need to include it in thewhereblock ofgenerateUpTo. Otherwise, it’s literally, “not in scope”. Example:If you want these functions to be used in multiple places, you could just accect rmax as an arguement:
Note – it looks like you also have some problems with your definition of
check… thepassandfailvalue there are just arguements ofcheck, 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:
Note, however, the name
rmaxin the definition ofnmaxis no longer significant. These functions are all exactly the same:Likewise, you don’t need to call it with a value named
rmax.