[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Pattern matching and list comprehensions



Mon, 17 Mar 2014 23:02:52 +0100 от Panicz Maciej Godek <godek.maciek@x>:
I think that there's a nice tradition among the Scheme programmers to
use the name "compose" to refer to a composition function. It is much
more descriptive than "dollar-asterisk" ("multiply dollars"? "a
millionare marries a star"? "jackpot"?), and hence more
reader-friendly, and unless you are doing some domain-specific
research, your programs usually won't get much longer because of that.
Yes (and I did so, too, at start), but `compose' is too long a word (compare it to Haskell's `.'). So I've decided to name procedure constructors in a unified manner:
1) their names should start in the same distinguishing character;
2) and they should be short, and, probably, operator-like.
`$' is not popular in the Report, so it was chosen to not clash with standard procedures.
Now, `*' seemed good for the compositions, because composition is a monoid operation for functions.
Likewise `$0' is a procedure that returns constant-returning function (that is, ($0 1 2 3) always returns (values 1 2 3), whenever called with any set of arguments), it is not something that costs zero dollars.
Once again: it was all for brevity.
Btw, how is "compose" defined traditionally?

As to the behaviour of "filter", it is not clear whether it should
behave as you described when more than one list is provided. Perhaps
it should rather iterate over their cartesian product? Or concatenate
the lists? That's one more thing to remember, and eventually one more
thing to forget. If you're doing something complex, don't let your
code pretend that it's something simple.
So that's a rule: when (filter) is fed with one list, it returns one list. When it's fed with several lists, it returns as many lists.
This is just another feature of Scheme utilized to make a procedure more general case.

С уважением,

denin@x
В ходе опроса отдельно фиксировалось название оператора мобильной связи, который был упомянут
первым – это позволило получить показатель приоритетной (top of mind) спонтанной известности. Позиции
операторов «большой тройки» по параметру «первое упоминание» примерно очень близки. Закономерно,
что чаще всего респонденты первым называли «своего» основного оператора (72-82%).
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports