def longMixedTerm(length, **aargs): return multimap( functionSource(trees.randomBinaryTree, length), [ mapI(trees.treeTerm(**aargs)) , mapI(trees.cleverFold) , mapI(snd) , avoidDuplication ])
def longMixedTerm(length, **aargs): return multimap(functionSource(trees.randomBinaryTree, length), [ mapI(trees.treeTerm(**aargs)), mapI(trees.cleverFold), mapI(snd), avoidDuplication ])
def myrandrange(a, b): return functionSource(randrange, a, b) multiply = mapI(lambda t: "%i * %i" % t) add = mapI(lambda t: "%i + %i" % t) substract = mapI(lambda t: "%i - %i" % t) fst = lambda s: s[0] snd = lambda s: s[1] # -- generators smallMultiplicationTable = multimap( myrandrange(1, 11), [ tuples , multiply , avoidDuplication , renderSymbols]) bigMultiplicationTable = multimap( myrandrange(1, 21), [ tuples , filterI(lambda t: t[0] > 10 or t[1] > 10) , multiply , avoidDuplication , renderSymbols]) additionUpTo = lambda maximum : multimap( myrandrange(1, maximum), [ tuples , add
def myrandrange(a, b): return functionSource(randrange, a, b) multiply = mapI(lambda t: "%i * %i" % t) add = mapI(lambda t: "%i + %i" % t) substract = mapI(lambda t: "%i - %i" % t) fst = lambda s: s[0] snd = lambda s: s[1] # -- generators smallMultiplicationTable = multimap(myrandrange( 1, 11), [tuples, multiply, avoidDuplication, renderSymbols]) bigMultiplicationTable = multimap(myrandrange(1, 21), [ tuples, filterI(lambda t: t[0] > 10 or t[1] > 10), multiply, avoidDuplication, renderSymbols ]) additionUpTo = lambda maximum: multimap(myrandrange(1, maximum), [ tuples, add, smallResult(maximum), avoidDuplication ]) substractionUpTo = lambda maximum: multimap(myrandrange( 2, maximum), [tuples, substract, nonNegative, avoidDuplication])