pointfree

    0热度

    3回答

    compress [email protected](_:_:_) = (ifte <$> ((==) <$> head <*> head.tail) <$> ((compress.).(:) <$> head <*> tail.tail) <*> ((:) <$> head <*> compress.tail)) xs 结果在类型错误,但我不明白为什么。它应该是相当于 compress [ema

    4热度

    4回答

    说,我们可以写这样的事: zipWith (,) [1,2,3] [4,5,6] 如果我们想元组3列表中,我们可以这样写: zipWith3(,,)[1,2,3] [4 ,5,6] [7,8,9] 我们还可以使用zipWith4 (,,,) zipWith5(,,,,)等等。 现在,我想要做同样的事情,但使用添加,而不是逗号运算符。 有没有办法在同一个简洁的方式来定义它不使用Lambda表达式

    2热度

    2回答

    这个问题与这个Function Composition VS Function Application有关,由antal s-z回答。 你如何得到这个? map has type (a -> b) -> [a] -> [b] head has type [a] -> a map head has type [[a]] -> [a] 为什么下面的代码有函数组合的类型错误? test :: [

    13热度

    2回答

    我一直在用Haskell玩一下,包括以无点形式练习写作功能。下面是一个示例函数: dotProduct :: (Num a) => [a] -> [a] -> a dotProduct xs ys = sum (zipWith (*) xs ys) 我想用无点形式写这个函数。下面是我在别处找到了一个例子: dotProduct = (sum .) . zipWith (*) 不过,我不明

    19热度

    3回答

    偶尔我会偶然发现我想表达的问题,“请使用最后一个参数两次”,例如为了写无点式或避免lambda。例如。 sqr x = x * x 可以写成 sqr = doubleArgs (*) where doubleArgs f x = f x x 或者考虑这个稍微复杂功能(从this question拍摄):如果有类似的功能 ins x xs = zipWith (\ a b -> a

    7热度

    1回答

    我一直在学习因子和J语言来实验无点编程。这些语言的基本机制看起来很清楚,但如何处理算法设计却是一种挑战。 对我来说,一个特别的困惑就是应该如何构造代码,以便用不同的参数进行实验。通过这个,我的意思是Mathematica和Matlab非常擅长的东西;你设置了一个算法,然后操纵变量并观察发生了什么。 如何在没有显式变量的情况下做到这一点?也许我在想这一切都是错误的。我应该如何用无点编程来解决这个问题

    15热度

    2回答

    鉴于: data TwoInts = TwoInts Int Int add'em :: TwoInts -> Int add'em (TwoInts a b) = a+b 是有可能写add'em,而不必命名a和b。喜欢的东西: add'em TwoInts = (+) -- (Note: Fails to type check)

    25热度

    2回答

    我编写了下面的代码,它需要一堆点并使用光泽库在屏幕上绘制它们。 let s = blocks pes pts = map (map mkPt) s {- stitches to points-} lines = map Line pts {-points to lines -} pict = Pictures lines {- lines to a picture -