A popular use case is
if any( "--help", "-?", "-h" ) == param then
usage
Junctions can be constructed by either
* using the module methods any, all, none and one of Lab419::Junctions
or
* by using junction methods of enumerables (1..3).all > 0
or
* by including Lab419::Junctions
Si tu veux construire un bateau ...
Ne rassemble pas des hommes pour aller chercher du bois, préparer des
outils, répartir les tâches, alléger le travail… mais enseigne aux
gens la nostalgie de l’infini de la mer.
If you want to build a ship, don’t herd people together to collect
wood and don’t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.
···
On Sat, Apr 18, 2009 at 4:58 PM, David Palm <dvdplm@gmail.com> wrote:
Enjoy
Junctions
A pure Ruby implementation of Junctions as planned for Perl6. [1]
Pretty sweet!
Did you look into how complex it would be to implement autothreading, like in Perl 6, too?
They are an abstraction of the code blocks, if you look at streams,
the second concept implemented in Lab419::functional we have exactly
the same pattern, delay is nothing more than a lambda.
As a matter of fact the main pleasure I have got from releasing code
in Ruby is that Ruby does all the work
and I can get the compliments, well I cannot because you have pointed
out that I have not done anything. Thank you very much
ok seriously now: I believe that this kind of abstraction is useful,
makes code shorter and even more readable.
Is it worth a package? Well maybe not, but what are you going to tell
a perl6 guru if he asks you if Ruby got Junctions? (Proud in Ruby was
indeed a key motivation, maybe that is bad, I dunno )
Look at this example:
if a_set.any > b_set.all then
would be
if a_set.any?{ | x | b_set.all?{ | y | x > y } } then
I kind of prefer to maintain code written in the first style.
Cheers
Robert
···
On Sat, Apr 18, 2009 at 11:38 PM, Denis Defreyne <denis.defreyne@stoneship.org> wrote:
If #<=> is defined I would do the same, but that is not necessarily
the case. ">" might implement something
where ! ( !(a>b) -> b>a) as e.g. superset, subset relationships. If
you are against such redefinitions, please read the example as
follows:
if a_set.any.superset?( b_set.all ) then
I wanted to make it clear that Junctions can be combined and thus
become a more powerful abstraction over relations.
Cheers
Robert
···
On Sun, Apr 19, 2009 at 4:27 PM, James Gray <james@grayproductions.net> wrote:
I imagine I would just do:
if a_set.max > b_set.max
# ...
end
--
Si tu veux construire un bateau ...
Ne rassemble pas des hommes pour aller chercher du bois, préparer des
outils, répartir les tâches, alléger le travail… mais enseigne aux
gens la nostalgie de l’infini de la mer.
If you want to build a ship, don’t herd people together to collect
wood and don’t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.