// BRY browser components: pure reducers and computed views. // State and view are numeric arrays. DOM and events are host capabilities. ::2.+8.++5.3.+5.++1.+4.++(@1#4,@2#3,@3#1)#4 [ !(:len(@1) == 2) @4 := @1[0] @5 := @1[1] ?(@2 == "step")[ !(@3 >= 1 && @3 <= 100 && :floor(@3) == @3) @5 := @3 ]:[ ?(@2 == "add")[@4 := @4 + @5]:[ ?(@2 == "subtract")[@4 := @4 - @5]:[ ?(@2 == "reset")[@4 := 0]:[!(false)] ] ] ] !(@4 >= -10000 && @4 <= 10000) < {@4,@5} ] ::2.+8.++5.3.+5.++1.+4.++.++2.9.5.++3(@1#4)#4 [ !(:len(@1) == 2) < {@1[0],@1[1],:abs(@1[0])} ] // Budget allocator, in whole units. Reject allocations over the limit. ::2.+8.++5.1.+2.+2.+5.3.1.++.5(@1#4,@2#3,@3#1)#4 [ !(:len(@1) == 2) @4 := @1[0] @5 := @1[1] ?(@2 == "limit")[ !(@3 >= 1 && @3 <= 10000 && :floor(@3) == @3) @5 := @3 ]:[ ?(@2 == "add" || @2 == "subtract")[ !(@3 >= 1 && @3 <= 1000 && :floor(@3) == @3) ?(@2 == "add")[@4 := @4 + @3]:[@4 := @4 - @3] ]:[ ?(@2 == "reset")[@4 := 0]:[!(false)] ] ] !(@4 >= 0 && @4 <= @5) < {@4,@5} ] ::2.+8.++5.1.+2.+2.+5.3.++2.9.5.++3(@1#4)#4 [ !(:len(@1) == 2 && @1[1] > 0) < {@1[0],@1[1],@1[1] - @1[0],:floor(100 * @1[0] / @1[1])} ]