[perl-python] 20050117, filter, map

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Xah Lee

    [perl-python] 20050117, filter, map

    © # -*- coding: utf-8 -*-
    © # Python
    ©
    © # the "filter" function can be used to
    © # reduce a list such that unwanted
    © # elements are removed.
    © # example:
    ©
    © def even(n): return n % 2 == 0
    © print filter( even, range(11))
    ©
    ©
    © # the "map" function applies a function
    © # to all elements of a list. Example:
    ©
    © def square(n): return n*n
    © print map(square, range(11))
    ©
    © ------------------------------------
    © # similar perl versions
    ©
    © use Data::Dumper;
    © sub even {return $_[0]%2==0};
    © print Dumper[ grep {even $_} (0..10)];
    ©
    ©
    © # sub square {$n=shift;$n**2 ;};
    © sub square {(shift)**2;};
    © print Dumper [ map {square($_)} (0..10)];
    ©
    © # the codes above showcase some syntax
    © # variations commonly found in perl code
    © # base
    ©
    © -------------------------
    ©
    © # in Mathematica for example, filter is
    © # akin to Apply and map is MapThread.
    © # The standard Map can be applied
    © # according to a level spec of trees
    © # and there's also MapAt, Nest,
    © # NestList...any many more powerful
    © # functions that manipulates trees.
    © # lisp languages often have a subset
    © # of it.
    ©
    © ----------------------------
    © Note: this post is from the Perl-Python
    © a-day mailing list at
    © http://groups.yahoo.com/group/perl-python/
    © to subscribe, send an email to
    © perl-python-subscribe@yahoo groups.com if
    © you are reading it on a web page,
    © program examples may not run because
    © html conversion often breaks the code.
    ©
    © Xah
    © xah@xahlee.org
    © http://xahlee.org/PageTwo_dir/more.html

  • Steven Bethard

    #2
    Re: [perl-python] 20050117, filter, map

    Xah Lee wrote:[color=blue]
    > © Note: this post is from the Perl-Python
    > © a-day mailing list at
    > © http://groups.yahoo.com/group/perl-python/[/color]

    Is there any chance you could post these all as part of the same thread?
    That would be really nice for those of us who aren't interested --
    then we could just ignore the thread...

    Thanks in advance,

    Steve

    Comment

    • Erik Max Francis

      #3
      Re: [perl-python] 20050117, filter, map

      Steven Bethard wrote:
      [color=blue]
      > Is there any chance you could post these all as part of the same thread?
      > That would be really nice for those of us who aren't interested --
      > then we could just ignore the thread...[/color]

      Or, better yet, not posting it at all. He's got his mailing list, what
      does he need to post it here for?

      --
      Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
      San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
      Make it come down / Like molasses rain
      -- Sandra St. Victor

      Comment

      • Steve Holden

        #4
        Re: [perl-python] 20050117, filter, map

        Erik Max Francis wrote:
        [color=blue]
        > Steven Bethard wrote:
        >[color=green]
        >> Is there any chance you could post these all as part of the same
        >> thread? That would be really nice for those of us who aren't
        >> interested -- then we could just ignore the thread...[/color]
        >[/color]
        You are looking for evidence of cluefulness where it seems unlikely to
        ever appear.[color=blue]
        >
        > Or, better yet, not posting it at all. He's got his mailing list, what
        > does he need to post it here for?
        >[/color]
        As I may have mentioned before, egotism can be the only possible reason.

        regards
        Steve
        --
        Steve Holden http://www.holdenweb.com/
        Python Web Programming http://pydish.holdenweb.com/
        Holden Web LLC +1 703 861 4237 +1 800 494 3119

        Comment

        • Nick Coghlan

          #5
          Re: [perl-python] 20050117, filter, map

          Steve Holden wrote:[color=blue]
          > As I may have mentioned before, egotism can be the only possible reason.[/color]

          I'd merely figured it as a textbook case of trolling - attention seeking
          behaviour, most likely indicative of a lack of self-esteem, rather than the reverse.

          Still, he does at least keep the [perl-python] mailing list tag, so automatic
          filtering isn't that difficult. It is an unfortunate shame that his
          consideration doesn't extend to removing the general Perl and Python discussion
          groups from his recipients list.

          Cheers,
          Nick.

          --
          Nick Coghlan | ncoghlan@email. com | Brisbane, Australia
          ---------------------------------------------------------------

          Comment

          • Martin Kissner

            #6
            Re: [perl-python] 20050117, filter, map

            Steven Bethard wrote :[color=blue]
            > Xah Lee wrote:[color=green]
            >> © Note: this post is from the Perl-Python
            >> © a-day mailing list at
            >> © http://groups.yahoo.com/group/perl-python/[/color]
            >
            > Is there any chance you could post these all as part of the same thread?
            > That would be really nice for those of us who aren't interested --
            > then we could just ignore the thread...[/color]

            I would appreciate that, too.
            But I fear this person doesn't even read the comments on his unwanted
            load.

            I guess I'll scorefile the "Subject" of these postings, too, to get rid of
            this.


            --
            Epur Si Muove (Gallileo Gallilei)

            Comment

            • Xah Lee

              #7
              Re: [perl-python] 20050117, filter, map

              erratum:

              the Mathematica Apply should've been Select.
              ....

              Xah
              xah@xahlee.org


              Comment

              • Xah Lee

                #8
                Re: [perl-python] 20050117, filter, map

                erratum:

                the Mathematica Apply should've been Select.
                ....

                Xah
                xah@xahlee.org


                Comment

                • Abigail

                  #9
                  Re: [perl-python] 20050117, filter, map

                  Steven Bethard (steven.bethard @gmail.com) wrote on MMMMCLVII September
                  MCMXCIII in <URL:news:iI6dn V_4Dafh0nbcRVn-gg@comcast.com> :
                  $$ Xah Lee wrote:
                  $$ > © Note: this post is from the Perl-Python
                  $$ > © a-day mailing list at
                  $$ > © http://groups.yahoo.com/group/perl-python/
                  $$
                  $$ Is there any chance you could post these all as part of the same thread?


                  Just killfile him, and stop replying. Remember, don't feed the trolls.



                  Abigail
                  --
                  my $qr = qr/^.+?(;).+?\1|;J ust another Perl Hacker;|;.+$/;
                  $qr =~ s/$qr//g;
                  print $qr, "\n";

                  Comment

                  • Charlton Wilbur

                    #10
                    Re: [perl-python] 20050117, filter, map

                    >>>>> "SH" == Steve Holden <steve@holdenwe b.com> writes:

                    SH> As I may have mentioned before, egotism can be the only
                    SH> possible reason.

                    Relevant links:

                    "On Ignoring Trolls":

                    "A Troll's Anthology":


                    He admits to being a troll, and he enjoys trolling. I suspect this
                    thread was intended to stir up a flame war among Perl and Python
                    users; all it's done is demonstrate how hopeless Xah is as a
                    programmer even in a language he claims to be an expert in.

                    Charlton



                    --
                    cwilbur at chromatico dot net
                    cwilbur at mac dot com

                    Comment

                    • Jürgen Exner

                      #11
                      Re: [perl-python] 20050117, filter, map

                      Abigail wrote:[color=blue]
                      > Steven Bethard (steven.bethard @gmail.com) wrote on MMMMCLVII September
                      > $$ Is there any chance you could post these all as part of the same
                      > thread?
                      >
                      > Just killfile him, and stop replying. Remember, don't feed the trolls.[/color]

                      True, except that he spreads lies about Perl and really bad code all over
                      the place.
                      If you don't tell people about how awful his skills are then they may
                      actually mistake his incompetency for flaws in Perl.

                      jue


                      Comment

                      • Tad McClellan

                        #12
                        Re: [perl-python] 20050117, filter, map

                        Erik Max Francis <max@alcyone.co m> wrote:[color=blue]
                        > Steven Bethard wrote:
                        >[color=green]
                        >> Is there any chance you could post these all as part of the same thread?
                        >> That would be really nice for those of us who aren't interested --
                        >> then we could just ignore the thread...[/color]
                        >
                        > Or, better yet, not posting it at all. He's got his mailing list, what
                        > does he need to post it here for?[/color]


                        There isn't much point in trolling if you don't have an audience.


                        --
                        Tad McClellan SGML consulting
                        tadmc@augustmai l.com Perl programming
                        Fort Worth, Texas

                        Comment

                        Working...