我正在UPENN Haskell Homework 6 Exercise 5,試圖以限定ruler function 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,... 其中流中的第n個元素(假定第一元素對應於n = 1)是最大的power of 2其中均分n。 我只是想出了一個主意,建它沒有任何整除測試: data Stream x = Cons x (Stream x) d
我一直在考慮這個代碼 public static class Logger
{
public static Func<ILogger> LoggerFactory;
private static readonly Lazy<ILogger> _log = new Lazy<ILogger>(LoggerFactory);
public static ILogger
我試圖按照foldr的術語定義原始遞歸,如A tutorial on the universality and expressiveness on fold第4.1章所述。 這裏是它 simpleRecursive f v xs = fst $ foldr g (v,[]) xs
where
g x (acc, xs) = (f x xs acc,x:xs)
然而,以上定義