--------------------------------------------------------------- Question: What is going on with wrap(s) => (c)=>concat(s,c,s); and wrap("w")("o") then returns "wow" ? --------------------------------------------------------------- First, concat is a built-in rex function that takes as many arguments as you like, each of which is a string, and returns a new string which is the concatenation of these strings. For example, rex > concat("you"," are ","a mudder"); you are a mudder Now, let's look at the wrap function. It starts with wrap(s) => ... So, when the user types wrap("w") it will make s equal to "w" and return whatever is on the right hand side of the =>. What is on the right hand side of the => in this case? It is (c) => concat(s, c, s). In other words, what is returned here is not a number, not a string, but a function! It's a function that whenever given some input c, that function will return the concatenation of s, c, and s. Let's try it. Let's do it this way... rex > blah = wrap("w"); Now, blah is the name of the thing that wrap("w") returned, which is a function that looks like this... (c) => concat("w", c, "w") blah is equal to this function. Notice that the "w"'s here are the "w" what we gave the wrap function and that function then plugged that "w" in for s. Aha!! So now, blah is the name of this function. Imagine that we run rex > blah("o") Now, "o" gets passed in as the value of c in the function above (the blah function) and we get back concat("w", "o", "w") which is "wow". Finally, notice that the notation wrap("w")("o") does the following: It first evaluates wrap("w") which returns the function above, namely (c) => concat("w", c, "w"). Now, it passes the "o" into that function, placing the "o" into the c slot of the function. This results in the output "wow". wow! - thanks to Prof Ran!!