PyPCASTLテストファイル

test1.pl

a = function(arg1,arg2,arg3)
{
    print(arg3)
}

a(1,2,3)

test2.pl

print("Hello")
print(" ,")
print("world!")

test3.pl

hoge = function(a,b,c)
{
    print(a+b+c)
}

hoge(1,2,3)

test4.pl

enclosure = function()
{
    i = 0;
    return(function(){i=i+1;print(i)})
}

c1 = enclosure()
c1()
c1()

c2 = enclosure()
c2()
c1()
c2()

test5.pl

a = function(i)
{
    print(1);
    print(i)
}

a.childset[1].childset[0].childset[1].childset[0] = "abc"
a(3)
a.childset[1].childset[1].childset[1].childset[0] = "Hello,World!"
a(5)

enclosure = function()
{
    i = 0;
    return(function()
	   {
	       i=i+1;
	       print(i)
	   })
}

c1 = enclosure()
c1()
c1()

c2 = enclosure()
c2()
c1()
c2()
c1()
c2()
c2()

print("Test")

test6.pl

fib = function(i)
{
    if(i==1){return(1)}
    if(i==2){return(1)}
    return(fib(i-1)+fib(i-2))
}

acfib = function(i,now,next)
{
    if(i==0){return(now)}
    return(acfib(i-1,next,now+next))
}

print(acfib(100,0,1))

usage:python pcastl.py "ふぁいるめい"
です。