Replies: 1 comment
-
|
ok, I made a prototype of the single-fold solution for this expression. I have used something called "histomorphism" that, in short, is a fold in which the accumulator is a trace of every step of the folding. Let's say we have in our grammar a For this specific model, the function would be def f( (index, data), history ):
if sum(data) > 3:
if history[0].index > -1 and history[0].index - index > 4:
return (index, history[0].data + 1) # here, history[0].data is the accumulator of the fold, starting with 0
else:
return (index, history[0].data)
else:
return history[0]the (badly scribbled) tree would be: (this could be simplified with a better domain specific language) I think for this purpose we can either go with supporting frequently used higher-order functions, such as map, filter, etc. and simply compose them. Or the foldWithTrace, which gives additional freedom to how Brush creates the models. @lacava do you have more examples for me to play with? 😄 |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I've been thinking about the TRH example from Notion.
I think the simplest way a human programmer without implement that would be with two folds and a "window" function between them. So, let's suppose that we have a timeseries organized as:
This is just a draft of a c++ code, and I'm assuming there is a function
windowthat generates a moving window view of a list, so,window(2, [1,2,3,4]) = [(1,2), (2,3), (3,4)].So, in short, for this particular example we just need the fold_right and window function, assuming Brush will evolve the functions passed as parameters to the folds.
Of course in our grammar we could have the different flavors of fold (Map, Filter, ...) and then we would have something like:
There is actually one way to do this procedure using a single pass (without having the window function). I'll look into that to see if the solution would make things easier or not.
Beta Was this translation helpful? Give feedback.
All reactions