Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30846

Re: fmap(), "inverse" of Python map() function

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; '[])': 0.09; 'received:mail-qc0-f174.google.com': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; 'lambda': 0.16; 'oct': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'saying': 0.18; 'meant': 0.21; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'implemented': 0.27; 'message-id:@mail.gmail.com': 0.27; 'fri,': 0.30; 'url:2012': 0.30; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'subject:" ': 0.36; 'url:in': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'header:Received:5': 0.40; 'your': 0.60; 'url:blogspot': 0.64; 'url:10': 0.65; 'special': 0.73
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=hwIfQoO93YHf36rabErerJFAAY53WWdlZHKPFr4FjYA=; b=uShSSyeTywBhumiF6sMM7kza9/7NOOFHF/2h9ozNlMQo9fUvGc3eoGvvfoOTB4dYNE ADzS6xfGAMZKrj1Z0VHAee8aVdW0c5iXfp9OmRzIANp61wrE64Zx00J8K/ybRFpw/S9j 7LeD/Iw1QodLBLNxDMlu1Qxug8tkEZcR9XZ/mikVp1NTDWLhq6aroXc+eIOC6kHQdkbq oahyBO3IzKMYSCz39UTVijIaFJQNXMWXy85/c6uh+k4swJQg7jJFAVXUMNyYrqKLgEGx HkPeari1Pq+7Gq1HMpuXSnyLzRbt159jVuj+iXWdOUQQtdp6Q0ERswoa0GjQ6jxwhF0N nDKg==
MIME-Version 1.0
In-Reply-To <CALwzidmE5_LyKfEGqAGeN0Uv+g1fFo+ztjhZdr3b3vbRRnTvJA@mail.gmail.com>
References <727ec5d8-d292-4012-ba87-da77a1040c6a@googlegroups.com> <CALwzidmE5_LyKfEGqAGeN0Uv+g1fFo+ztjhZdr3b3vbRRnTvJA@mail.gmail.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Fri, 5 Oct 2012 18:52:41 -0400
Subject Re: fmap(), "inverse" of Python map() function
To Ian Kelly <ian.g.kelly@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1877.1349477604.27098.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349477604 news.xs4all.nl 6983 [2001:888:2000:d::a6]:42148
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30846

Show key headers only | View raw


On Fri, Oct 5, 2012 at 5:31 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Fri, Oct 5, 2012 at 2:19 PM, vasudevram <vasudevram@gmail.com> wrote:
>>
>> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html
>
> Your fmap is a special case of reduce.

So is map.

def map(f, seq):
    return reduce(
        lambda rseq, newpre:
            rseq.append(f(newpre)) or rseq,
        seq,
        [])

"X is a special case of reduce" is basically the same as saying "X can
be implemented using a for loop". If it's meant as a complaint, it's a
poor one.

-- Devin

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

fmap(), "inverse" of Python map() function vasudevram <vasudevram@gmail.com> - 2012-10-05 13:19 -0700
  Re: fmap(), "inverse" of Python map() function Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-05 15:31 -0600
  Re: fmap(), "inverse" of Python map() function Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-05 15:43 -0600
  Re: fmap(), "inverse" of Python map() function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-10-05 18:52 -0400
  Re: fmap(), "inverse" of Python map() function Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-05 17:24 -0600
  Re: fmap(), "inverse" of Python map() function Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-10-05 19:30 -0400
    Re: fmap(), "inverse" of Python map() function vasudevram <vasudevram@gmail.com> - 2012-10-06 11:57 -0700
      Re: fmap(), "inverse" of Python map() function vasudevram <vasudevram@gmail.com> - 2012-10-06 15:07 -0700
      Re: fmap(), "inverse" of Python map() function vasudevram <vasudevram@gmail.com> - 2012-10-06 15:07 -0700
    Re: fmap(), "inverse" of Python map() function vasudevram <vasudevram@gmail.com> - 2012-10-06 11:57 -0700

csiph-web