5m
comment Differentiate a trigonometric function using prolog
hello, and welcome to Stack Overflow! you need to clarify your question; as it stands it is unclear and will probably be closed for that reason. be sure to include your code snippets, and your sample queries and expected results.
16m
revised Powerset Function 1-Liner
some last touches
3h
revised How to reduce boilerplate of pattern matching in a list comprehension for existence of a single item
added 172 characters in body
4h
comment What is the difference between a cyclic list and an infinite list in haskell?
@sth IIUYC, you refer to the title only, but in the context of the question's text it is clear I think that the OP meant the repeating list, either achieved through actual pointer manipulation, or through copying on elements, indefinitely. Of course [1..] or cycle [1..] is not actually cyclic, or did you mean something else?
4h
revised Powerset Function 1-Liner
add code
4h
revised Powerset Function 1-Liner
add code
6h
comment Powerset Function 1-Liner
and an empty list represents no possible values. That's what the title of that famous paper by P. Wadler alludes to, "How to replace failure by a list of successes" - each element of a list represents successful computation of that value, so empty list represents a failure to compute any values. (the "pattern matching" terminology in that paper refers to parsing, not pattern matching as in Haskell).
6h
comment Powerset Function 1-Liner
no. "show all possibilities of" is how the nondetermnism monad operates. It is achieved by defining join xss = concat xss, i.e. defining xs >>= f = concatMap f xs. Any singleton list represents a nondeterministic entity with one possible value. A two-elements list represents a non-deterministic entity with two possible values. In "true" nondeterminism we imagine it holding these values simultaneously; in real computers this may be implemented by two values which are explored sequentially, i.e. a list. Which is the same, in Prolog.
15h
comment What is the difference between a cyclic list and an infinite list in haskell?
yes, exactly, like that lambda term you've shown. "fixpoint" is general, "Y combinator" is very specific; my point was that just as in lambda calculus, the self-reference ("sharing") is emulated through copying of terms (data), in Y (because in lambda calculus reduction is defined through textual substitution).
16h
comment Pattern-Matching mixed with guards
you could write accumul l f = case l of [] -> 0; (x:xs) | 5 < 10 -> ...; ... which actually mixes pattern matching with guards.
17h
comment What is the difference between a cyclic list and an infinite list in haskell?
yeah, just finished reading. :) you could also mention the cse optimization and -no-cse flag explicitly.
17h
comment What is the difference between a cyclic list and an infinite list in haskell?
on the other hand, with cyclic list the entire length of the prefix will be held in memory whereas with infinite only the length of the frontier in use will be held, which might be as short as 1 element. I guess that's "some cases" that you mention in the end of your answer. :)
17h
comment What is the difference between a cyclic list and an infinite list in haskell?
could fix' be called _Y perhaps? because this is what it is, after all -- the Y combinator, emulating sharing with copying of data.
17h
revised How to reduce boilerplate of pattern matching in a list comprehension for existence of a single item
added 18 characters in body
18h
revised How to reduce boilerplate of pattern matching in a list comprehension for existence of a single item
use forM_, d'oh.
19h
revised How to reduce boilerplate of pattern matching in a list comprehension for existence of a single item
added 40 characters in body
20h
revised How to reduce boilerplate of pattern matching in a list comprehension for existence of a single item
deleted 4 characters in body
20h
answered How to reduce boilerplate of pattern matching in a list comprehension for existence of a single item
2d
comment Source of my syntax error
your code is full of tabs. at the very least, always have a let keyword on its own line.
2d
comment Clarify role of list monad operator
@chi second that. f (g x) x is actually (f =<< g) x.
1 2 3 4 5