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


Groups > comp.lang.python > #51674

Re: Lambda function Turing completeness

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.107
X-Spam-Level *
X-Spam-Evidence '*H*': 0.83; '*S*': 0.04; 'argument': 0.05; 'itself.': 0.14; '(lambda': 0.16; '13th': 0.16; 'lambda': 0.16; 'notation': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'passing': 0.19; 'python?': 0.22; '31,': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'anonymous': 0.31; 'received:google.com': 0.35; 'possible': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'number:': 0.66; 'jul': 0.74; '13)': 0.84; 'functions)': 0.84; 'musical': 0.84; 'fibonacci': 0.91; '2013': 0.98
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 :content-type; bh=hVnBzNE2OzZUkzUBechoV0bIwpUJZsUxUUjm2sjq0uo=; b=gudPUXOqQZ4yP8SXORuvSoT0pZ5fwlHBNFPmCy2SOkgXLzpOGzTr9NFAJd5Z1s9eM3 u6A4DjiO1T9ndRMs6MJ6VPdqK/jTjmd0ZW+AmLGtR4Ks/eMnmwJRTR5Eox8chM/Z3H9G eWIOYuE34yUWrd4BBu/fhfUFMFroDljy5QPvGiZgfawHCeqg8bUXt1EMgVid6nLlpv63 9zC3cr3xTlH+l0Kulu9VtULFUFwOEaqMN9wYySu4i9wUZ8wIMJj1DFb0PSyPbBeEwxTW Lht0vq33jEOPckS9a3gjGqOpD5ZYkHprN/ugb+B+hEk/iLHXpJrb1p9+MprGjuw1tFn5 fjfQ==
X-Received by 10.68.36.132 with SMTP id q4mr81394434pbj.118.1375290505919; Wed, 31 Jul 2013 10:08:25 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <5CB71036-C359-4211-8B3B-62B17AACF88E@gmail.com>
References <5CB71036-C359-4211-8B3B-62B17AACF88E@gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 31 Jul 2013 11:07:45 -0600
Subject Re: Lambda function Turing completeness
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
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.40.1375290509.1251.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375290509 news.xs4all.nl 15919 [2001:888:2000:d::a6]:52236
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51674

Show key headers only | View raw


On Wed, Jul 31, 2013 at 12:53 AM, Musical Notation
<musicdenotation@gmail.com> wrote:
> Is it possible to write a Turing-complete lambda function (which does not depend on named functions) in Python?

Yes, lambda functions are Turing-complete.  You can get anonymous
recursion by defining the function to take a recursive function
argument and then passing it to itself.  For example, this will
(inefficiently) give you the 13th Fibonacci number:

(lambda f, n: f(f, n))(lambda f, n: n if n < 2 else f(f, n-2) + f(f, n-1), 13)

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


Thread

Re: Lambda function Turing completeness Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-31 11:07 -0600

csiph-web