Ruby Murray, a Ruby port of Perl’s Sub::Curry (with added Ruby
goodness), is now available in it’s first 0.1.2 release.
Ruby Murray allows block arguments to be supplied prior to calling (to
be ‘curried’) and also supports a range of features that allow arguments
to be populated in arbitrary order and with complex processing.
cool naming, nice functionality, easy using.
AFAIK this is a instantiation of the Design Pattern called “Command” by
the Gang of Four.
i can not imagine a problem where i needed such flexible argument list.
can anyone provide a motivation example in ruby?
i’d suggest to add a small sample of usage to the docs.
– henon
cool naming, nice functionality, easy using.
AFAIK this is a instantiation of the Design Pattern called “Command” by
the Gang of Four.
i can not imagine a problem where i needed such flexible argument list.
can anyone provide a motivation example in ruby?
i’d suggest to add a small sample of usage to the docs.
– henon
I’m not entirely sure where you’d use this sort of feature either, but
for the uninformed (such as myself)…
Oh, I never said it was useful
in fact it is very useful for most elegantly implementing undo/redo
commands. i was just curious about other applications.
thank’s for the link to the cookbook. i did only find the link to the
perl version at first.
– Henon
cool naming, nice functionality, easy using.
AFAIK this is a instantiation of the Design Pattern called “Command” by
the Gang of Four.
i can not imagine a problem where i needed such flexible argument list.
can anyone provide a motivation example in ruby?
i’d suggest to add a small sample of usage to the docs.
– henon
Oh, I never said it was useful
Actually, I don’t think there’s anything in Ruby that can’t be done
(better) some other way, but currying is one of those higher-order
things that every (decent) language should have ;).
James Edward G. II also came up with a good example in the quiz
summary, based on his LazySpice spice (included in this release):
# Lazy Evaluation meets Currying...
class LazySpice < Curry::SpiceArg
def initialize( &promise )
super("LAZYSPICE")
@promise = promise
end
def spice_arg( args ) # called to provide the missing
argument
[@promise.call]
end
end
logger = lambda do |time, message|
puts "[#{time.strftime('%I:%M:%S %p %m/%d/%y')}] #{message}"
end
log_now = logger.curry(LazySpice.new { Time.now })
log_now["First Message."] # => [12:47:53 PM 02/01/06] First
Oh, I never said it was useful
in fact it is very useful for most elegantly implementing undo/redo
commands. i was just curious about other applications.
Ahh, well, looks like I spoke too soon there.
Thanks for your kind comments
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.