rampion

Washington, DC

del.icio.us/rampion

Age: 36

Mathematician, programmer, and researcher; with interests in algorithmic design, software engineering theory, and massively parallel computing. I'm also a keyboard junkie and an aspiring language nerd.

1d
comment Haskell pattern matching on vectors
If not, then what you need is a version of inits for Data.Vector, which wouldn't be too hard to implement using init. inits [ a_0, a_1 ... a_n ] = [ [], [a_0], [a_0, a_1], [a_0, a_1, a_2], ..., [a_0, a_1, ..., a_n] ], so you could do fmap f . inits.
1d
comment Haskell pattern matching on vectors
It depends on the definition of f. If there exists g s.t. f [a_0...a_i] = g (f [a_0...a_{i-1}]) a_i forall i and b s.t. f [] = b, then scanl g b [a_0 .. a_n] will yield [ f [], f [a_0], f [a_0,a_1], f [a_0, a_1, a_2] ..., f [a_0, a_1, ... a_n ] ]. Such implementations are often more efficient, as they only need to do O(n) work, rather than O(n^2).
2d
comment Haskell pattern matching on vectors
@matthias that's a scan
2d
comment Haskell pattern matching on vectors
matthias: it depends. Do you want to convert a vector to another vector of the same length? Use fmap. A single value? Use fold. A selection of the elements? Use filter. With both lists and vectors, specialized higher-order functions exist to make various tasks both more efficient and easier for others to read.
2d
revised Haskell pattern matching on vectors
added 200 characters in body
2d
answered Haskell pattern matching on vectors
Apr
21
accepted Replacing singleton data types with a data family
Apr
21
comment Replacing singleton data types with a data family
dfeuer: but I also need access to the structure of the final type, which I can't get from proxies.
Apr
21
comment Replacing singleton data types with a data family
dfeuer: this is a simplified example for the question, but it allows you to do type-level logic without worrying about the inability of GHC (pre8) to reason about injectivity by carting around the arguments. For example, or :: (Boolean a, Boolean b) => SBool (a || b); or = case orProof of OrProof c -> c gives the old NB: ‘||’ is a type function, and may not be injective ambiguity error.
Apr
21
comment Replacing singleton data types with a data family
dfeuer: it could. That's besides the question, though.
Apr
21
asked Replacing singleton data types with a data family
Apr
18
awarded Notable Question
Apr
13
accepted Pattern synonym can't unify types within type-level list
Apr
12
asked Tell Haddock to use a different base URL for hyperlinked identifiers from other packages
Apr
10
awarded Nice Question
Apr
8
comment Haskell Vector performance woes
the genuine sieve of erastothenes
Mar
30
revised Pattern synonym can't unify types within type-level list
deleted 128 characters in body
Mar
30
answered Pattern synonym can't unify types within type-level list
Mar
30
comment Pattern synonym can't unify types within type-level list
dfeuer: aha, thanks
Mar
30
asked Pattern synonym can't unify types within type-level list
1 2 3 4 5