Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Full-fledged functions + recursion
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sriram Krishnan  
View profile  
 More options Mar 25 2005, 2:23 am
From: "Sriram Krishnan" <srir...@gmail.com>
Date: Fri, 25 Mar 2005 12:53:23 +0530
Local: Fri, Mar 25 2005 2:23 am
Subject: Full-fledged functions + recursion

This now works (just checked the code in)

def fact(i):
 if i < 1:
  return 1
 else:
  return i * fact(i - 1)

print fact(10)

We can recurse to any depth we want (until we hit the 4GB memory limit)- and
the only problem we run into is the integers start overflowing (as I'm
mapping to C data types). Compare this to CPython where I hit a recursion
depth of around 989.

In Smoke, I was able to recurse till somewhere around a million stack frames
deep before I got bored :)

Sriram


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google