Fat JSON
I make heavy use of a similar thing in PHP. I have a function "lookup" which lets me say:<p><pre><code>    lookup($foo, array('bar', 'baz' 15, 'quux'))
</code></pre>
This is equivalent to any of the following:<p><pre><code>    $foo->bar->baz[15]->quux
    $foo->bar->baz[15]['quux']
    $foo->bar['baz'][15]->quux
    $foo->bar['baz'][15]['quux']
    $foo['bar']->baz[15->quux
    ... and so on
</code></pre>
It's useful in Drupal when the required data is often at the end of a long chain of objects-containing-arrays-containing-objects-....<p>I've been a bit naughty with its types for the sake of convenience: if a non-array is given as the second argument, it's wrapped as a singleton array, ie.<p><pre><code>    lookup(array('foo' => 'bar'), 'foo') === 'bar'
</code></pre>
Also if any of the components aren't found, it returns NULL, ie.<p><pre><code>    lookup(array('foo' => NULL), 'foo') === lookup(array(), 'foo')
</code></pre>
It would be theoretically better to return an empty array on error and a singleton array on success, since they can be distinguished, but in practice that's so far down the list of problems with PHP that it's not worth the effort of adding such wrappers at the moment.<p>A really nice thing about this function is that it curries nicely:<p><pre><code>    $find_in_foo = partially_apply('lookup', $foo)

    $get_blah = partially_apply(flip('lookup'), 'blah')

    $find_in_foo('x') === lookup($foo, 'x')

    $get_blah($foo) === lookup($foo, 'blah')
</code></pre>
Actually, my argument-flipping function is already curried, so I can just say:<p><pre><code>    $get_blah = flip('lookup', $foo)
</code></pre>
This currying is great for filtering, mapping, etc.