in reply to Re: Re: Are strings lists of characters?
in thread Are strings lists of characters?
UPDATE: changed while loop to one liner to irk the Java types >:)use strict; sub NEXT { $_[0]->() } sub string_to_char_iter { my $string = shift; $string = reverse $string; sub { chop $string } } sub get_all { my $iter = shift; my (@list,$char); push @list,$char while $char = NEXT $iter; return @list; } my $string = join '', 'a' .. 'z'; my $iter = string_to_char_iter $string; print $_,$/ for map uc, get_all($iter);
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) 3Re: Are strings lists of characters?
by John M. Dlugosz (Monsignor) on Oct 18, 2002 at 14:29 UTC | |
by Ovid (Cardinal) on Oct 18, 2002 at 17:01 UTC | |
by John M. Dlugosz (Monsignor) on Oct 18, 2002 at 20:51 UTC |