Join = reduce
I was driving today and I realized that join is just a form of reduce. Here’s some perl6:
sub join(Str $string, @array) {
@array.reduce: { $^a ~ $string ~ $^b }
}
It works exactly as expected.
Posted Mon, Jan 26, 2009If you're interested in being notified when new posts are published, you can subscribe here; you'll get an email once a week at the most.