4 ms·
Does the function have to be referentially transparent?
by m0th87 14y ago
Does the function have to be referentially transparent?
- coffeemug 14y agoNo. E.g., you could write r.table('foo').update(lambda row: row.merge({'bar': row['bar'] + 1 })). A shortcut for this is r.table('foo').update({'bar': r['bar'] + 1 }). Neither is referentially transparent, and both work.
- m0th87 14y agoThis is beyond awesome, and thanks for the follow-ups!
- jdoliner 14y agoI believe both of those functions are referential transparent because they're pure functions. An example of a non referential transparent function would be: r.table('foo').update(lambda row: {'bar' : r.table('bar').get(row["bar_id"])) This still works but gets evaluated in a different way to make sure every secondary winds up with the same value.