Exemple #1
0
def permuteFloats(lst):
    startList = \
        pipe(lst,
        [
            F(List.map)(
                Basics.toFloat
            )
        ])


    newElements = \
        pipe(startList,
        [
            List.sort,
            F(List.map)(
                lambda n:
                    (n + 0.5)

            ),
            lambda items:
                List.cons(0.5, items)

        ])

    return pipe(newElements, [
        F(List.map)(List.singleton),
        F(List.map)(lambda x: List.append(startList, x))
    ])
Exemple #2
0
def map5(lst):
    return \
        pipe(lst,
        [
            F(List.map5)(
                lambda a, b, c, d, e:
                    F(Tuple.pair)(
                        a,
                        F(Tuple.pair)(
                            b,
                            F(Tuple.pair)(
                                c,
                                F(Tuple.pair)(
                                    d,
                                    e
                                )
                            )
                        )
                    )
                ,
                List.toElm([ 10, 20, 30 ]),
                List.toElm([ 5, 8, 7 ]),
                List.toElm([ 1, 2, 3, 4, 5 ]),
                List.toElm([ 33, 97, 103 ])
            )
        ])
Exemple #3
0
def a1a1f2(n):
    return \
        F(F(lambda x, y:
            ((x * 10) + y)
        )(
            1
        ))(
            n
        )
Exemple #4
0
def concatMap(lst):
    return \
        F(List.concatMap)(
            F(List.map)(
                lambda n:
                    (n * 5)

            ),
            lst
        )
Exemple #5
0
def partition(lst):
    return \
        F(List.partition)(
            lambda n:
                (F(Basics.modBy)(
                    2,
                    n
                ) == 0)
            ,
            lst
        )
Exemple #6
0
def a1a1a1f3(n):
    return \
        F(F(F(lambda x, y, z:
            ((x * 100) + ((y * 10) + z))
        )(
            1
        ))(
            2
        ))(
            n
        )
Exemple #7
0
def factorial2(n):
    return \
        pipe(F(List.range)(
            1,
            n
        ),
        [
            F(List.foldl)(
                lambda a, b: a * b,
                1
            )
        ])
Exemple #8
0
def unzip(lst):
    return \
        pipe(lst,
        [
            F(List.map)(
                lambda x:
                    F(Tuple.pair)(
                        x,
                        (x * 3)
                    )

            ),
            List.unzip
        ])
Exemple #9
0
def incr(n):
    return \
        F(lambda x:
            (x + 1)
        )(
            n
        )
Exemple #10
0
def any(lst):
    return \
        F(List.any)(
            lambda x:
                (4 == x)
            ,
            lst
        )
Exemple #11
0
def pythagTest(n):
    return \
        F(lambda x, y:
            ((x * x) + (y * y))
        )(
            9,
            n
        )
Exemple #12
0
def all(lst):
    return \
        F(List.all)(
            lambda x:
                (1 == x)
            ,
            lst
        )
Exemple #13
0
def ranks(lst):
    return \
        pipe(lst,
        [
            F(List.indexedMap)(
                Tuple.pair
            ),
            F(List.sortBy)(
                Tuple.second
            ),
            F(List.map)(
                Tuple.first
            ),
            F(List.indexedMap)(
                Tuple.pair
            ),
            F(List.sortBy)(
                Tuple.second
            ),
            F(List.map)(
                Tuple.first
            ),
            F(List.map)(
                lambda n:
                    (n + 1)

            )
        ])
Exemple #14
0
def foldr(lst):
    return \
        pipe(lst,
        [
            F(List.foldr)(
                List.cons,
                List.toElm([  ])
            )
        ])
Exemple #15
0
def map2(lst):
    return \
        pipe(lst,
        [
            F(List.map2)(
                List.range,
                List.toElm([ 1, 2, 3 ])
            )
        ])
Exemple #16
0
def filter(lst):
    return \
        pipe(lst,
        [
            F(List.filter)(
                lambda x:
                    (x == 4)

            )
        ])
Exemple #17
0
def f4Test(n):
    return \
        F(lambda a, b, c, d:
            ((a + b) * (c + d))
        )(
            1,
            2,
            3,
            n
        )
Exemple #18
0
def map2Pythag(lst):
    return \
        pipe(lst,
        [
            F(List.map2)(
                lambda x, y:
                    ((x * x) + (y * y))
                ,
                List.toElm([ 3, 5, 7 ])
            )
        ])
Exemple #19
0
def map3(lst):
    return \
        pipe(lst,
        [
            F(List.map3)(
                lambda x, y, z:
                    ((x * 100) + ((y * 10) + z))
                ,
                List.toElm([ 10, 20, 30 ]),
                List.toElm([ 5, 8, 7 ])
            )
        ])
Exemple #20
0
def sortWith(lst):
    return \
        F(List.sortWith)(
            lambda a, b:
                F(Basics.compare)(
                    F(lambda n:
                        F(Basics.modBy)(
                            10,
                            n
                        )
                    )(
                        a
                    ),
                    F(lambda n:
                        F(Basics.modBy)(
                            10,
                            n
                        )
                    )(
                        b
                    )
                )
            ,
            lst
        )
Exemple #21
0
def map4(lst):
    return \
        pipe(lst,
        [
            F(List.map4)(
                lambda a, b, c, d:
                    ((a + b) * (c + d))
                ,
                List.toElm([ 10, 20, 30 ]),
                List.toElm([ 5, 8, 7 ]),
                List.toElm([ 1, 2 ])
            )
        ])
Exemple #22
0
def f5Test(n):
    return \
        F(lambda a, b, c, d, e:
            F(Tuple.pair)(
                a,
                F(Tuple.pair)(
                    b,
                    F(Tuple.pair)(
                        c,
                        F(Tuple.pair)(
                            d,
                            e
                        )
                    )
                )
            )
        )(
            1,
            2,
            3,
            4,
            n
        )
Exemple #23
0
def tail(lst):
    return \
        F(List.tail)(
            lst
        )
Exemple #24
0
def sum(lst):
    return \
        F(List.sum)(
            lst
        )
Exemple #25
0
def reverse(lst):
    return \
        F(List.reverse)(
            lst
        )
Exemple #26
0
def repeat(n):
    return \
        F(List.repeat)(
            n,
            42
        )
Exemple #27
0
def member(lst):
    return \
        F(List.member)(
            42,
            lst
        )
Exemple #28
0
def take(lst):
    return \
        F(List.take)(
            2,
            lst
        )
Exemple #29
0
def minimum(lst):
    return \
        F(List.minimum)(
            lst
        )
Exemple #30
0
def product(lst):
    return \
        F(List.product)(
            lst
        )