|
|
|
|
|
by kragen
3597 days ago
|
|
I'm glad you like it! Maybe I'll get used to it in time myself. I do still use things like "argmin", which you could argue is a "keyword"; by argmin_{x ∈ S} f(x), I mean what you would express in Python as min(S, key=f), which ends up translating to something like this in C: int min_found = 0;
T min;
U min_item;
for (iter it = first(S); hasNext(it); it = advanced(it)) {
U item = itemAt(it);
T val = f(item);
if (!min_found || val < min) {
min_found = 1;
min = val;
min_item = item;
}
}
do_whatever_with(min_item);
Maybe this is what someone earlier meant when they said this paper algorithm notation was still too hard to translate into code, but I feel like argmin (over a finite set) is a sufficiently familiar concept that there's no need to spell it out in more detail, and indeed it's a standard library function in Python. |
|