Hot answers tagged

4

On my machine, your original Haskell version run on two copies of the "sa3_10000" test file takes about 20 seconds, while your Go version takes about 2 seconds. Note that profiled GHC binaries run significantly slower, even if you don't generate a profile, so you'll want to make sure you're timing an unprofiled binary when making these comparisons....


2

Interestingly enough, this can be solved with no math at all. The things to know are: show turns an Int into a String A String is internally actually [Char], so you can map to and from strings as you would lists. read converts a String to the datatype it represents (but does not work with Chars) Putting those together, the steps to turn an integer into a ...


2

It looks pretty good. When working with a module that overlaps Prelude, like Data.Vector.Storable, it's more usual to import it with the qualified keyword: import qualified Data.Vector.Storable as V and skip the import Prelude as P. Then, in the rest of the code, all functions from the vector module get qualified, and none of the functions from the prelude ...


1

I am not an expert at type level programming, but from my experience with folds I know that you can add an extra parameter to the result type to implement foldl in terms of foldr. Here is what that would look like in this case: newtype VecBuilder s m a = VecBuilder { buildVec :: s -> Vec m a } unfold' :: forall n a. SNatI n => (a -> (a, a)...


1

Parsing with Precedence I gather you want to add precedence to your operators, so you can write: 15 | !6 & 12 in place of: (15 | (!6) & 12) with the understanding that ! binds more tightly than & which binds more tightly than |. Fortunately, Parsec has built in support for this in the Text.Parsec.Expr module. The way you use it is to write a ...


1

Adding final version, as suggested by @haruo Below code snippet was originally authored by user Noughtmare in response https://www.reddit.com/r/haskell/comments/odfpoe/looking_for_ways_to_improve_performance_of/?utm_source=share&utm_medium=web2x&context=3 at haskell's reddit group with minor tweaking at my end: https://www.reddit.com/r/haskell/...


Only top voted, non community-wiki answers of a minimum length are eligible