Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am learning Haskell, studying for a midterm. there is a test quiz I'm looking at at the moment with questions on type inference. some of the questions contain forward slashes and I have no idea what they represent. the goal is to determine the type of the function by looking at its variables. here are some examples of the questions im supposed to find the type of:
f1 x = (/x)
f3 x = (x/)
f5 = (1/)
f6 = (/2)
I have googled with no luck, what does the forward slash mean?
These are sections: the expression (/x) is equivalent to \y -> y / x and (x/) is equivalent to \y -> x / y.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Python:
I have researched a lot into this, but as a beginner I don't understand the solutions, let alone apply them to my simple problem:
def min_max(xs):
xs = []
for i in xs:
y = (min, max)
return y
"local variable 'y' referenced before assignment"
I don't understand why this does NOT work!!
I've defined Y in the line before return, i know there is another way to do it, but i really need to know why this method is wrong!
Thanks!
assuming that min and max are defined somewhere else....
The loop for i in xs will go around once for each item in xs. Since xs is empty, the loop will not run at all. So, y is never set.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
main = print $ smallestFactor 15
factors n = [x | x <- [2..n], n `mod` x == 0]
smallestFactor n = min[factors n]
I understand that it's a pretty trivial question but someone told me that I could use min get grab out the smallest value of a element list. Though, I'm not exactly sure how one is suppose to use it.
You mean minimum :: Ord a => [a] -> a. Plus, you're erroneously using square brackets when you should be using parentheses. Don't use square brackets when you're not explicity defining a list!
Here's the corrected part:
smallestFactor n = minimum (factors n)
The rest of your code is fine.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I type this into my texteditor:
boombang xs = [ if x < 10 then ”BOOM!” else ”BANG!”
But when trying to load it, my terminal denies it and and says:
Probably some dumb rookie mistake, but I can't seem to find the solution...:/
There are two problems here.
The first is, you're not using plain ASCII quotation marks (U+0022) ". You're using right quotation marks (U+201D) ”. There's probably a keyboard setting you're using that's causing this, and using certain text editing programs can also prevent this.
Secondly, you seem to be either missing a right bracket. As pointed out, this is probably meant to be part of a list comprehension. You need to write all of the list comprehension for it to work.
The corrected code is:
boombang xs = [if x < 10 then "BOOM!" else "BANG!" | x <- xs]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I am learning semantics of Haskell and there I came across this question:
I have tried it but still unable to conclude the answer. It will be great if someone explains me how to prove this one. Thank you.
Just a sketch -> Since pn(s) for fixed n is morphism Ninf -> N , that is set of Integers into Integer, this proof can be simplified using this relation into proof of transitivity over integers
[1,0,0 .. ] -> [2,0,0 ..] -> [3,0,0 ..] -> ...
I am sure you can find even more interesting one
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm trying to use do notation to only return a list element if it's even:
ghci> do { x <- [1,2,3]; if (even x) [x] else []}
<interactive>:43:36: parse error on input `else'
What am I doing wrong?
In addition, please note if this code is non-idiomatic.
You forgot the "then".
Also, i'm not really sure which Monad is this..
do { x <- [1,2,3]; if (even x) then [x] else []}