Arrows' pronunciation

Viewed 92

I'm not an English native speaker, so I'm wondering how to read out the related code, like:

  • (a -> A, b-> B) how to read this? "a right arrows A, b right arrows B"?
  • for( a <- list) this? "a left arrow list", or just "for a in the list"?
  • case _ => a this? hmmm...

I can understand the function but can only describe the meaning instead of the specific arrows. Shall I just speak out as "for a in the list"? I think that might be not so clear to the other listeners sometimes.

How to communicate with others in English for these arrow characters?

1 Answers

Perhaps a general notion of map as a synonym for a function

a -> A                        map a to A
b -> B                        map a to B
(a -> A, b-> B)               map tuple (a -> B) to tuple (b -> B)
for (a <- list) yield a + 1   map a in list to a + 1
case _ => a                   map anything to a      

or phrase "from _ to _"

a -> A                        from a to A
b -> B                        from b to B
(a -> A, b-> B)               from tuple (a -> B) to tuple (b -> B)
for (a <- list) yield a + 1   from a in list to a + 1
case _ => a                   from anything to a 

or phrase "if _ then _"

a -> A                        if a then A
b -> B                        if b then B
(a -> A, b-> B)               if tuple (a -> B) then tuple (b -> B)
for (a <- list) yield a + 1   if a in list then a + 1
case _ => a                   if anything then a

There is a result claiming equivalence between the concept of function and implication, hence we can see the process of mapping as act of reasoning, so "if _ then _" might be fine.

As a side note, consider the difference between

for (...) yield (...)   map every element
for (...) (...)         execute side-effect for each element
Related