From: chad@... Date: 2017-01-10T13:29:15+00:00 Subject: [ruby-core:79035] [Ruby trunk Feature#12854] Proc#curry should return an instance of the class, not Proc Issue #12854 has been updated by Chad Brewbaker. Another pattern is Proc#multilens(tin, lenses, tout); where "tin" is a transformation from the input argument list to lenses, "lenses" are the intermediate functions, and "tout"is a mapping from the intermediate functions to an output argument list. ~~~ruby id = ->(*a){*a} add = -> (a,b}{a+b} decrement = -> (a){a-1} q = id.multilens([0,0,1],[add,decrement],[1,0]) q(1,2,3) == [add.call(1,1),decrement.call(2)].trans(1,0) == [2,1].trans(1,0) == [1,2] ~~~ There is also a conveyor belt pattern, but I haven't thought of a good syntax. There are k FIFO queues. The lenses are stacked across the queues in a directed acyclic graph. You also have buffer lenses that can allow inputs to keep flowing for a fixed amount. Yes, I played a lot of Factorio over Christmas :) https://wiki.factorio.com/Belt_transport_system If you can draw a belt pattern on a doughnut with d holes without crossing; that says something about the complexity of how many cores you can run it in parallel on, and how hard it is to map on an FPGA. Hoping to add SIMD, OpenCL, and FPGA support to Fiddle so lambdas can run at full machine bandwidth on basic types. Also, for more complexity you could drop the DAG requirement and have arbitrary directed graphs; allowing the convayor belts to be recurrent. Also, buffers could be arbitrary Ruby data structures allowing for even more flexibility. Conveyor belts happen in the real world where you have a speed of light latency connection. The number of packets that can be in flight is the distance divided by the latency of placing a packet on the wire. At the speed of light two processors placed in the opposite corners of your laptop (30cm apart) can only ping-pong around 500 million times a second even if their latency to process a packet is Plank's constant. ---------------------------------------- Feature #12854: Proc#curry should return an instance of the class, not Proc https://bugs.ruby-lang.org/issues/12854#change-62442 * Author: Ryan Davis * Status: Feedback * Priority: Normal * Assignee: * Target version: ---------------------------------------- ~~~ ruby class ChainedProc < Proc end ChainedProc.new { |x, y, z| 42 }.curry.class # => Proc ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: