Re[2]: What app would show off Prothon?

Lenard Lindstrom <[email protected]> Fri, 16 Jul 2004 13:36:58 -0700 (Pacific Daylight Time)
Newsgroups gmane.comp.lang.prothon.user
Message-ID <Mahogany-0.66.0-4294611243-20040716-134117.00@pop3.norton.antivirus>
On Thu, 15 Jul 2004 19:50:34 -0700 Mark Hahn <[email protected]> wrote:

> Lenard Lindstrom wrote:
> 
> > The language itself has not been targetted at any particular problem
> > set. So it is anybodies guess what applications Prothon is best
> > suited for. But with integrated internationalization and thread
> > support maybe Prothon will be a natural for implementing
> > client-server programs on multiprocessor systems.
> 
> I'm thinking it doesn't have to be a complete application but just an
> interesting problem subset or maybe a different way to attack a problem.
> Anything fresh and different that fits well with prototype's simplicity.
> 
> The only thing I've noticed new is the direct use of module objects as
> prototypes and there isn't enough meat there for a topic.
> 
> 
This is an example taken from "Teach Yourself Scheme in Fixnum Days"
that makes use of Prothon's enhanced generator function. I can not
test it because of Prothon bugs (yes I am submitting a bug report).

"""Exports sameFringe list fringe test function"""

def List?(o):
    return o.protos_[0] is List

def fringeHelper(tree):
    print(tree)
    if List?(tree):
        for node in tree:
            fringeHelper(node)
    else:
        yield tree

gen fringe(tree):
    fringeHelper(tree)

def iterDead?(iter):
    try:
        a.next()
        return False
    except StopIteration:
        return True

def sameFinge?(treeA, treeB):
    """Check if two objects have the same fringe
       ==> Boolean
       (
       treeA (object): A tree (List) or other object.
       treeB (object): A tree (List) or other object.
       )
       Does a recursive comparison on two lists to check
       if they have the same fringe."""
    iterA = fringe(treeA)
    iterB = fringe(treeB)
    try:
        while iterA.next() == iterB.next():
            pass
        return False
    except StopIteration:
        pass
    return iterDead?(iterA) and iterDead?(iterB)



Lenard Lindstrom
<[email protected]>