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 ])
# We can load many templates at once without noticeable speed or space penalty. shortTemplate = Template("templates/shortLines-Eichendorfschule.svg") mediumTemplate = Template("templates/mediumLines-Eichendorfschule.svg") longTemplate = Template("templates/longLines-Eichendorfschule.svg") veryLongTemplate = Template("templates/veryLongLines-Eichendorfschule.svg") divisionTemplate = Template("templates/division-Eichendorfschule.svg") def divisionOhneRest(divisor=[1,10], quotient=[100,300]): _divisor = randrange(*divisor) _quotient = randrange(*quotient) return "%i / %i" % (_divisor * _quotient, _divisor) # -- Useful maps for working with iterators renderSymbols = mapI(lambda term: term.replace("*", "•").replace("/", ":")) orderOfOperation = filterI(lambda term: ("+" in term or "-" in term) and "*" in term) brackets = filterI(lambda term: "(" in term) doubleBrackets = filterI(lambda term: term.count("(") >= 2) def smallResult(n): return filterI(lambda term: eval(term) <= n) def bigResult(n): return filterI(lambda term: eval(term) >= n) def resultBetween(a, b): return filterI(lambda term: a <= eval(term) <= b) nonNegative = filterI(lambda term: 0 <= eval(term))
shortTemplate = Template("templates/shortLines-Eichendorfschule.svg") mediumTemplate = Template("templates/mediumLines-Eichendorfschule.svg") longTemplate = Template("templates/longLines-Eichendorfschule.svg") veryLongTemplate = Template("templates/veryLongLines-Eichendorfschule.svg") divisionTemplate = Template("templates/division-Eichendorfschule.svg") def divisionOhneRest(divisor=[1, 10], quotient=[100, 300]): _divisor = randrange(*divisor) _quotient = randrange(*quotient) return "%i / %i" % (_divisor * _quotient, _divisor) # -- Useful maps for working with iterators renderSymbols = mapI(lambda term: term.replace("*", "•").replace("/", ":")) orderOfOperation = filterI(lambda term: ("+" in term or "-" in term) and "*" in term) brackets = filterI(lambda term: "(" in term) doubleBrackets = filterI(lambda term: term.count("(") >= 2) def smallResult(n): return filterI(lambda term: eval(term) <= n) def bigResult(n): return filterI(lambda term: eval(term) >= n)