6.12.5.2. Test

Start python section to interscript/felix/tests/func_test.py[1 /1 ]
     1: #line 135 "felix_func.ipk"
     2: import sys
     3: sys.path = ['']+sys.path
     4: from interscript.felix.model.funcat import function, constant, identity
     5: from interscript.felix.model.funcat import cat_function
     6: from interscript.felix.model.funcat import function_product, function_sum
     7: from interscript.felix.model.funcat import input_adapter, output_adapter
     8: import math
     9: 
    10: sin = function(math.sin)
    11: print sin(0.5)
    12: 
    13: cos = function(math.cos)
    14: print cos(0.5)
    15: 
    16: square = function(lambda x: x * x)
    17: print square(0.5)
    18: print (sin & square)(0.5)
    19: print (cos & square)(0.5)
    20: 
    21: add = function(lambda x: x[0] + x[1])
    22: print add((1,2))
    23: 
    24: delta = function(lambda x: (x,x))
    25: print delta(7)
    26: print (delta & add)(7)
    27: print (square * square)((2,3))
    28: 
    29: sin2pcos2 = delta & ((sin & square) * (cos & square)) & add
    30: print sin2pcos2(0.5)
    31: 
    32: sign = function(lambda x: (x<0,x)) # sign 1 if negative else 0
    33: print sign(1), sign(-1)
    34: 
    35: negate= function(lambda x: -x)
    36: print negate(1), negate(-1)
    37: 
    38: absolute = sign & (identity() + negate)
    39: 
    40: print absolute(-4), absolute(4)
    41: 
    42: c = constant(1)
    43: print c(99)
    44: 


6.12.5.2.1. Test output