Feature Requests item #1673203, was opened at 2007-03-04 00:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1673203&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: paul rubin (phr)
Assigned to: Nobody/Anonymous (nobody)
Summary: add identity function

Initial Comment:
Requested and assigned to Raymond at his suggestion:

http://groups.google.com/group/comp.lang.python/msg/603870361743c85c

There should be an identify function identity(x)=x.

I suggest it also take and ignore an optional second arg: identity(x1,x2)=x1.  
The second arg can be useful in some generator expressions:

foo = (x for x in bar if condition(x) and identity(True, memoize(x))

That allows calling memoize (or some other function) on the selected elements 
in the genexp, and disposing of the returned value.  It's sort of like the 
const function (K combinator) to go along with the identity function's I 
combinator.  OK, the above is not really in the functional spirit, but it's 
been useful.

There could conceivably be also an actual const function 
const(k)=partial(identity,k) but I can't remember needing that in Python code.  
The two-arg identity function (uncurried version of const) is probably enough.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1673203&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to