You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the module has a queryInlines : (Inline i -> List a) -> Block b i -> List a.
An improvement on this, that would make the function more flexible and help with performance, could be to follow the fold pattern, ie:
foldInlines: (Inlinei->a->a) ->a->Blockbi->a
With this, queryInlines can be expressed in terms of this more generic function:
queryInlines f block = foldInlines (\inline acc -> f inline :: acc)[] block
This would allow the function to iterate on accumulators different than lists, avoiding intermediate allocations, and inserting more or less than one item per inline.
The example could be rewritten as:
Right now the module has a
queryInlines : (Inline i -> List a) -> Block b i -> List a
.An improvement on this, that would make the function more flexible and help with performance, could be to follow the fold pattern, ie:
With this,
queryInlines
can be expressed in terms of this more generic function:This would allow the function to iterate on accumulators different than lists, avoiding intermediate allocations, and inserting more or less than one item per inline.
The example could be rewritten as:
The text was updated successfully, but these errors were encountered: