SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
No more Blub for me, thank you, Vicar.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry wrote:Where I'm exactly stuck is when I call this function using my test case:
The value of x is 2. But s1 is 1. But the map function should evaluate to 2. I think I'm missing some basic understanding of anonymous functions.
Matthew Brown wrote:
My tip for getting a concise expression would be to step away from the code, and try and express what the result of the map function means. Complete the sentence "map(s1, f) contains x if...". Bonus points if you use the word "exists" somewhere.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry wrote:if x exists in s and maps to the result of applying the function on x (f(x)).
Matthew Brown wrote:
Joe Harry wrote:if x exists in s and maps to the result of applying the function on x (f(x)).
No, x doesn't have to exist in s. Using your doubling example, 6 doesn't exist in {1, 2, 3}, but does exist in {2, 4, 6}.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Matthew Brown wrote:Pretty much, yes. And "s has an element <insert condition here>" is exactly what the exists method is for.
Wen Tong Lin wrote:Hello everyone,
Its good to see this thread. I was wondering if anybody can give me a hint on how to define the filter function? The description says "Returns the subset of `s` for which `p` holds.". I'm confuse why p is not define as a Set, but instead it's a function with the same signature and return type.
My understanding was:
s = {1,2,3,4,5}
p = {2,3,4}
then it returns {2,3,4} ?
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Wen Tong Lin wrote:Hi guys,
I'm stuck with implementing map method. My solution looks very imperative. Any hints? This is what I did.
loop from -bound to +bound assign value to i
if s(i) is true return a function that does f(i)
No more Blub for me, thank you, Vicar.
Wen Tong Lin wrote:Thanks Chris. I already submitted my exercise without the answer. Let me check that thread, for the sake of learning.
No more Blub for me, thank you, Vicar.