Thanks everyone,

I am discarding the proposal for now and I will resubmit a new one next
week. At this point, it is clear the "imperative assignment" is a big
departure and any new proposal must not include that.

Just one last point. Let's change the Pythagorean Triplets example to store
values in Map. We can do this:

for a <- 1..20,
    b <- 1..20,
    c <- 1..20,
    a*a + b*b == c*c,
    reduce: %{} do
  acc -> Map.put(acc, {a, b}, c)
end

The whole  "reduce: %{} do acc ->" is a construct that you have to learn
and, although it plays by the language syntax rules, it is quite specific
to "for". Maybe your answer is, "that's why I don't use for", but that's
partially the point: we already have for, it has its own rules, but they
are verbose, not frequently used, while still having a lot of potential
inside them. As much potential as "for" in most languages.

How can we teach someone how to do a map_reduce without telling them about
map_reduce? I don't believe it is possible today without this additional
cognitive load. You do need to learn where it comes from at some point, but
we don't learn how to paint by first learning the name of all colors.

Some more replies below (quotations in bold).

*> let: section_counter <- 1, let: lesson_counter <- 1*

My concern about this is that `<-` in for means extracting something from
the collection, so giving it another meaning inside an option can be quite
confusing.

*> for {k, v} <- Enum.reverse(list), reduce: acc: %{} do*

My very early prototypes (I have been working on this for several weeks
now) used keyword lists but there is one big issue. Variables in Elixir are
identified by their name and their context (which is important for variable
hygienes in macros). A keyword list has atom as keys and they don't carry
the context, which means we can't use atoms (keys in keyword lists) to
express variables.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LmO8v%2BdzAtvNd8Ni%2BmWFgL0R%2B%3Dz-sVntuyp0ow%2BzaH4g%40mail.gmail.com.

Reply via email to