Coda Deep Comparison Op on Objects & Lists

i sometimes create complex data objects like trees and object structures using a combination of List(), Object(), ParseJSON() and _Merge().

this results in data structures that are TREEs or GRAPHs and have a lot of internal structure that reflects the structure of the objects being processed. eg: a dependency graph for a hierarchical WBS (work breakdown structure) for a project with a resource-availability tree and computing a Critical Path Analysis on it to find the optimal sequence of tasks to minimize the project duration.

i was surprised to discover that the EQUALS operator ‘=’ performs a complete tree traversal comparison of the two operands! so you can easily compare two lists-of-lists, objects, trees, and graphs !

what i mean is;

when you compare two complex objects (or two lists-within-lists-within-lists) to see if they are equal, coda will go through both structures node-by-node until one of them is not exactly equal to the other (when it returns FALSE) or until it has compared every node (in which case it returns TRUE).

mostly, this is just an interesting piece of ‘coda-trivia’. but in this case (the PERT-graph critical-path-analysis application) it is an amazingly useful feature. because writing such a recursive tree-traversing comparison algorithm in pure coda would be VERY difficult - so i thought i would need a pack to do it in javascript. but no. you just need the equals sign!

now, this prompts me to ask; what were they thinking in coda at the time they developed this feature? did they really expect that makers would be making complex data structures way back then?

it feels like the scientist who (just for kicks) put a tortoise in a wind-tunnel and discovered it had a wind-resistance-factor almost as good as a fighter jet ! like, huh? what was god thinking? :wink:

max

5 Likes