コード例 #1
0
def longMixedTerm(length, **aargs):
    return multimap(
        functionSource(trees.randomBinaryTree, length),
        [ mapI(trees.treeTerm(**aargs))
        , mapI(trees.cleverFold)
        , mapI(snd)
        , avoidDuplication ])
コード例 #2
0
def longMixedTerm(length, **aargs):
    return multimap(functionSource(trees.randomBinaryTree, length), [
        mapI(trees.treeTerm(**aargs)),
        mapI(trees.cleverFold),
        mapI(snd), avoidDuplication
    ])
コード例 #3
0
# 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))
コード例 #4
0
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)