[Stackless] infinite recursion

Jonathan Hogg jonathan at onegoodidea.com
Mon Jun 16 09:30:36 CEST 2003


On 13/6/03 14:53, Chao, Heng Sun wrote:

> Something I forgot to mention: I am learning functional programming, hardcore!
> As a result, I'm trying to avoid imperative programming as much as possible.
> Like a spoken language, you will learn functional much faster if do not use
> *any* imperative constructs.

Like a spoken language, you will learn functional programming much faster if
you do not use an imperative language ;-)

Python is not optimised for recursion, has limited functional combinators,
doesn't support currying, partial evaluation, or laziness, and is
dynamically typed. All of these are good reasons to learn functional
programming elsewhere, then come back to Python later.

As always, I recommend Haskell.

    <http://www.haskell.org/>

The very excellent Glasgow Haskell Compiler (GHC) now includes an
interpreter that can be driven from the command-line in a similar manner to
Python.

    <http://www.haskell.org/ghc/>

For example:

    % ghci
       ___         ___ _
      / _ \ /\  /\/ __(_)
     / /_\// /_/ / /  | |      GHC Interactive, version 6.0, for Haskell 98.
    / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
    \____/\/ /_/\____/|_|      Type :? for help.

    Loading package base ... linking ... done.
    Prelude> let fact 0 = 1; fact n = n * fact (n-1)
    Prelude> fact 5
    120
    Prelude> fact 50
    30414093201713378043612608166064768844377641568960512000000000000
    Prelude> fact 5000
    42285779266055435222010642002335[...100 lines of number here...]0000000
    Prelude> 

Defining definitions at the command line is a little clunky for anything
other than a one-liner, but it's easy enough to reload modules from files.
You can also compile modules and use them with others that are interpreted.

Python's list comprehensions are inspired by Haskell, so it's interesting to
learn and then compare with the design of Python.

You might also want to consider O'Caml (though I've never been a fan of the
ML syntax).

    <http://www.ocaml.org/>

Jonathan

_______________________________________________
Stackless mailing list
Stackless at www.tismer.com
http://www.tismer.com/mailman/listinfo/stackless




More information about the Stackless mailing list