This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exercise: MacrosAndCodeEvaluation-2 | |
# Write a macro called *times_n* that takes a single numeric argument. It should define a function | |
# called *times_n* in the caller's module that itself takes a single argument, and that multiplies | |
# the argument by *n*. So, calling *times_n(3)* should create a function called *times_3*, and | |
# calling *times_3(4)* should return 12. Here's an example of it in use: | |
# | |
# defmodule Test do | |
# require Times | |
# Times.times_n(3) | |
# Times.times_n(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A message is supposed to come in like this but we don't know if the fields are filled out. | |
message = %{ | |
route: %{ | |
destination: "Tim", | |
source: "Paul" | |
}, | |
type: :friend_request, | |
payload: %{ | |
size: 32, | |
content: %{ |
NewerOlder