15 Mar 2013 10:26
FW: 3/15/2013 10:26:49 AM
Andrew Savige <ajsavige <at> yahoo.com.au>
2013-03-15 09:26:49 GMT
2013-03-15 09:26:49 GMT
http://www.occamobile.com/zhvrm/htdza/hsp/gr/vo 3/15/2013 10:26:49 AM . Andrew Savige
http://www.occamobile.com/zhvrm/htdza/hsp/gr/vo 3/15/2013 10:26:49 AM . Andrew Savige
> btw here is an example :
>
> the code, applied on (1, 2, 3, 4) would return (1, 3). Thanks
so you want to check every element for oddity of its value, not its index, right?
<at> list = grep{$_%2} <at> array;
cheers,
0--gg-
> On 16 May 2012 13:15, damien krotkine <dkrotkine <at> gmail.com> wrote:
> > Hi,
> >
> > I'm using this code to get a list of only the odd elements of an
> > array. The resulting list must have the same order as the array.
> >
> > map { state $f; ($_) x (++$f%2) } <at> array;
> >
> > I'm looking for advice to make it shorter or nicer. Everything in perl
> > 5.12 is allowed, but must pass use strict. I've failed at using the
> > '..' operator to act as a flip/flop operator...
> >
> > thanks,
> > dams
>
Hi,
I'm using this code to get a list of only the odd elements of an
array. The resulting list must have the same order as the array.
map { state $f; ($_) x (++$f%2) } <at> array;
I'm looking for advice to make it shorter or nicer. Everything in perl
5.12 is allowed, but must pass use strict. I've failed at using the
'..' operator to act as a flip/flop operator...
thanks,
dams
The story behind Acme::Bleach and its many cousins: http://www.perlmonks.org/?node_id=967004 Feedback and anecdotes welcome. Thanks, /-\
So, A few years back, I started to write a manual page about Perl secret operators, with the goal of getting it into the official Perl documentation at some point. Somehow I got interested in that again, and started to really work on it. The current work in progress is availabled at: https://github.com/book/perlsecret I've already included most of the feedback from the discussions on ~~<>. Patches welcome. When it's stabilized enough, I'll send a patch to p5p. -- -- Philippe Bruhat (BooK) Too many believe only in the belief. (Moral from Groo The Wanderer #58 (Epic))
Hi,
While doing some tests/research on secret operators, I stumbled upon this
one in my one-liners:
~~<>
Obviously, this should be named "the sperm operator". It's only useful
in list context. Just like sperm cells work better when there are many
of them.
Now, if you want to get a number from that line you just read, you
could use this variation:
~~<>+0
which we could name the fertilisation, conception, fecundation or
syngamy operator, except the flagella (~~) has become useless, since
the +0 operator (ovum?) already provides scalar context. So it's just
the same as <>+0.
I have no idea if this operator is really new, or if someone else found
and named it already before today. My Google-fu is too weak to make
useful searches on it.
--
--
Philippe Bruhat (BooK)
No matter who you may be, there is always someone who is a little worse
because he thinks he is a little better.
(Continue reading)Begin forwarded message: Date: Mon, 26 Dec 2011 11:13:48 +0200 From: Shlomi Fish <shlomif <at> shlomifish.org> To: golf <at> perl.org Subject: New Golf Server - http://golf.shinh.org/ Hi all, there's a new Golf server called Anarchy Golf, which supports Perl (perl-5.12.4) and many other languages: http://golf.shinh.org/ One feature of it is that the solutions are revealed after a while, whose lack really bothered me in codegolf.com. Its source code is in a GitHub repository and it has an IRC channel on Freenode. Regards, Shlomi Fish -- -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "The Human Hacking Field Guide" - http://shlom.in/hhfg <Botje> Khisanth =~ s/must sleep/must give Botje all my money/ . — Freenode’s #perl(Continue reading)
It is kind of obvious when you unfold the loop, but what is the best
abuse of this very deprecated perl feature?
//Makholm
#!/usr/bin/perl
$japh = pack "C*", 113, 123, 32 .. 122, 125;
$_ = q(49 6 8 7 91 26 13 12 7 19 22 9 91 43 22 9 15 91 19 26 24 16 22 9 79);
s/ (\d+) \s* /"\x24[=$1; print substr($japh, length($japh), !!$japh)"/eegox;
hi!
Just a little JAPH for convert decimal to binary.... Feel free to comment
it ;)
----------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
eval { <at> ARGV} or die("No args") ;
foreach my $arg( <at> ARGV) {
my $convert = unpack("B*",pack("N", $arg));
my <at> convertsp = split("", $convert);
my $count = 0;
foreach ( <at> convertsp) {
unless ($convertsp[$count] == 1) {
$convertsp[$count] = "" ;
$count++;
}
}
print("$arg: <at> convertsp \n");
}
exit 0;
This is something people often ask for. The stock answer is that
regexes aren't the correct solution, but really it's not so hard.
This validates Gregorian MM/DD/CCYY dates, for example:
qr#^
(?: 0[1-9] | 1[012] )
/
(?:
0[1-9] | 1[0-9] | 2[0-8]
| (?<! 0[2469]/ | 11/ ) 31
| (?<! 02/ ) 30
| (?<! 02/
(?= ...
(?:
.. (?: [02468][1235679] | [13579][01345789] )
| (?: [02468][1235679] | [13579][01345789] ) 00
)
)
) 29
)
/
[0-9]{4}
\z
#x
Wow, nice to se something happening on this list. :) Would anyone like to rate my old JAPH below? (Don't know how to rate it, but maybe it can be fun to figure that out... ;) - Salve (Oslo.pm) -- -- #!/usr/bin/perl sub AUTOLOAD{$AUTOLOAD=~/.*::(\d+)/;seek(DATA,$1,0);print# Salve Joshua Nilsen getc DATA}$"="'};&{'"; <at> _=unpack("C*",unpack("u*",':4 <at> ,$'.# <sjn <at> foo.no> '2!--"5-(50P%$PL,!0X354UC-PP%/0\`'."\n"));eval "&{' <at> _'}"; __END__ is near! :)
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |
RSS Feed1 | |
|---|---|
21 | |
7 | |
17 | |
4 | |
44 | |
1 | |
8 | |
1 | |
4 | |
9 | |
3 | |
34 | |
23 | |
70 | |
2 | |
1 | |
4 | |
55 | |
11 | |
39 | |
9 | |
1 | |
9 | |
16 | |
1 | |
3 | |
5 | |
1 | |
4 | |
20 | |
51 | |
44 | |
3 | |
15 | |
18 | |
39 | |
11 | |
7 | |
37 | |
43 | |
74 | |
8 | |
19 | |
16 | |
11 | |
5 | |
34 | |
26 | |
81 | |
3 | |
97 | |
57 | |
14 | |
69 | |
43 | |
40 | |
118 | |
109 | |
67 | |
20 |