Click here to Skip to main content
15,904,500 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
F-ES Sitecore19-Jun-17 4:54
professionalF-ES Sitecore19-Jun-17 4:54 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
lopatir19-Jun-17 5:14
lopatir19-Jun-17 5:14 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
F-ES Sitecore19-Jun-17 5:15
professionalF-ES Sitecore19-Jun-17 5:15 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
TSapiga19-Jun-17 20:22
TSapiga19-Jun-17 20:22 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Pete O'Hanlon19-Jun-17 20:34
mvePete O'Hanlon19-Jun-17 20:34 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
TSapiga19-Jun-17 21:31
TSapiga19-Jun-17 21:31 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Harrison Pratt20-Jun-17 0:46
professionalHarrison Pratt20-Jun-17 0:46 
GeneralRe: Programming question: Map, Filter, and Reduce PinPopular
harold aptroot19-Jun-17 5:07
harold aptroot19-Jun-17 5:07 
No, M/F/R with reasonable limitations is not Turing complete, so it cannot cover everything, so there must be procedures that do other things than mapping, filtering or reducing. Besides, if you factor out the functions that you map over things, or the predicates, or the reduction function, those often have no M/F/R internally - they're more likely to be just some small arithmetic circuit over scalars (of course you could write arbitrary functions there..).

More practically, I'd say there are a couple of common patterns that are not secretly M or F or R (or some combination of them) in disguise:
  1. Arbitrary iteration (instead of over a collection). "Do this thing X times" is not a map, filter or reduce. Sure you could prepare a list of size X and then map over it, but that's a hack to force it to be done with the M/F/R paradigm, not a trick revealing that all loops are maps. Also if the iterations depend on each other, that's not a map, maybe a fold. "Do this until [cond]" is even less of a M/F/R. I'm sure someone would like to argue at this point that such repetitions are merely parts of M/F/R if you look at a broader picture, but that is far from always true. Consider for example numerical algorithms that iterate until they converge, or simulations of systems that have to be evolved for X time steps.
  2. Things that involve a "scatter". That's a lot of things. For example, inverting a permutation - again you can do some dirty hack, but the regular way is iterating result[input[i]] = i for all valid i, which is not like an M/F/R or parts thereof. The "inner" code chooses where to write, so it's not just mapping some function over the array.
  3. Almost anything that involves a more complicated data structure such as a heap, tree, disjoint sets, graphs (sometimes. some adjacency matrix algorithms do have an M/F/R structure). It will almost always rely on a specific ordering of side effects, you can't usually just apply operations to the data structure in a different order and get the same (or equivalent) results. Even if the global structure is "sort of like a map", I would argue that the requirement to evaluate strictly in-order makes it not-a-map - proper maps should not have an ordering constraint between evaluations of the function it is applying.
That, I think, covers most non-trivial algorithms, except naive matrix multiplication and its generalizations (such as Floyd–Warshall).
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Marc Clifton19-Jun-17 6:52
mvaMarc Clifton19-Jun-17 6:52 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
PIEBALDconsult19-Jun-17 5:10
mvePIEBALDconsult19-Jun-17 5:10 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
ZurdoDev19-Jun-17 5:54
professionalZurdoDev19-Jun-17 5:54 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Caslen19-Jun-17 5:45
Caslen19-Jun-17 5:45 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Sander Rossel19-Jun-17 6:24
professionalSander Rossel19-Jun-17 6:24 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
kmoorevs19-Jun-17 5:53
kmoorevs19-Jun-17 5:53 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Sander Rossel19-Jun-17 6:28
professionalSander Rossel19-Jun-17 6:28 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Gary Wheeler20-Jun-17 2:26
Gary Wheeler20-Jun-17 2:26 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
KBZX500020-Jun-17 3:20
KBZX500020-Jun-17 3:20 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
Kirk 1038982120-Jun-17 7:43
Kirk 1038982120-Jun-17 7:43 
GeneralRe: Programming question: Map, Filter, and Reduce Pin
H.Brydon20-Jun-17 16:51
professionalH.Brydon20-Jun-17 16:51 
GeneralMicrosoft haters PinPopular
Ygnaiih19-Jun-17 2:29
professionalYgnaiih19-Jun-17 2:29 
GeneralRe: Microsoft haters Pin
den2k8819-Jun-17 2:34
professionalden2k8819-Jun-17 2:34 
GeneralRe: Microsoft haters Pin
BillWoodruff19-Jun-17 3:33
professionalBillWoodruff19-Jun-17 3:33 
GeneralRe: Microsoft haters Pin
den2k8819-Jun-17 3:36
professionalden2k8819-Jun-17 3:36 
GeneralRe: Microsoft haters Pin
lopatir19-Jun-17 2:53
lopatir19-Jun-17 2:53 
JokeRe: Microsoft haters Pin
Richard Deeming19-Jun-17 3:17
mveRichard Deeming19-Jun-17 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.