In Haskell we can write an argument of a function as pair@(x,y). That means that pair is the pair with the two elements x and y. Is there something similar in Julia? For example if I have a list of pairs, I would like to do
You seem happy with the solution, but I was wondering if there is some miscommunication going on. Specifically, do you really want or need as patterns? Your example doesn’t actually use pair in the function, so it seems like an example of a case where the as pattern isn’t needed and isn’t used. As opposed to some other non-Julia/non-Haskell snippet like:
map(pair@(x,y) -> x+pair, my_list_of_pairs)
where you would be using the binding to pair established by the as pattern. I don’t think there is anything like an as pattern in Julia or provided in any package I know of. However MLStyle.jl is definitely worth checking out for fancy pattern matching.