[Haskell-cafe] Re: functional graphs

2008-01-21 Thread Mirko Rahn
erwise = (z,t,w,s+w) : rt (s+w)bs ((r,c,v):ys) {- *Main> round_trip $ CGraph [0..5] (\ x y -> mod (x+y) 4) [(0,4,0,0),(4,5,1,1),(5,3,0,1),(3,1,0,1),(1,3,0,1),(3,2,1,2),(2,3,1,3),(3,5,0,3),(5,4,1,4),(4,0,0,4)] -} Have fun! /BR, Mirko Rahn

[Haskell-cafe] Re: Optimizing cellular automata evaluation (round 2)

2007-12-03 Thread Mirko Rahn
cate 148 ' ' ++ "X" in mapM_ putStrLn $ take 1 $ iterate f init is only 3 times slower than your quite complex, hard to follow and hard to debug implementation. As always, I prefer to write most code in Haskell, quick, easy, nice, reasonable fast, ...

[Haskell-cafe] Re: New slogan for haskell.org

2007-11-30 Thread Mirko Rahn
hat a Haskell program that verifies these values will depend on an external intset implementation. Or uses another data structure, for example some Set_of_Intervals... /BR, Mirko Rahn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Re: New slogan for haskell.org

2007-11-29 Thread Mirko Rahn
s able to calculate a_{23448481} = 594261577728 and a_{2500} = 192365946 in 50s and ~1GB memory usage. /BR, Mirko Rahn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: map/reduce example

2007-11-27 Thread Mirko Rahn
P is the number of processes involved. There are also some O(log P) algorithms, counting activation messages and summing up in two wave fronts these numbers. These algorithms are formulated for message passing environments with the capability to send a message to a speci

[Haskell-cafe] Re: About Fibonacci again...

2007-11-08 Thread Mirko Rahn
The Rabbit Sequence: 1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,... This nasty acquaintance of mine asked the students to write down a simple procedure which generates the sequence after the infinite number of units of time. Of course, any finite prefix of it. In te

Re: [Haskell-cafe] Is "take" behaving correctly?

2007-09-13 Thread rahn
pref_eq k xs ys = take k xs == take k ys This seems to be a straightforward implementation with good properties. Actually, no, at least not if implemented naively. I choosed this example, since I stumbled on this question last week. Reputable mathematicians doing "combinatorics on word

Re: [Haskell-cafe] Is "take" behaving correctly?

2007-09-12 Thread rahn
take 1000 [1..3] still yields [1,2,3] You can think about take n as: Take as much as possible, but at most n elements. This behavior has some nice properties as turned out by others, but there are some pitfalls. We have length . take n /= const n in general, instead only length . take

Re: [Haskell-cafe] Comments and/or Criticisms

2007-09-10 Thread rahn
countCS :: [Char] -> [(Char, Int)] I use this count :: (Ord a, Num b) => [a] -> (a -> b,[(a,b)]) count xs = ( flip (Map.findWithDefault 0) m , Map.assocs m ) where m = Map.fromListWith (+) $ zip xs $ repeat 1 which returns the frequencies list as well as a query function that I found m

Re: [Haskell-cafe] Style

2007-08-24 Thread Mirko Rahn
div n 5 of 0 -> mzero q -> return (q,q) ) I tend to not use |iterate|, when it is known in advance, which prefix of the so constructed infinite list is used. /BR -- -- Mirko Rahn -- Tel +49-721 608

Re: [Haskell-cafe] Re: monad subexpressions

2007-08-03 Thread Mirko Rahn
some common idioms, where others need some help... /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: monad subexpressions

2007-08-03 Thread Mirko Rahn
using memcpy() I like to hear that you would reject it either. /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: monad subexpressions

2007-08-03 Thread Mirko Rahn
d for? So rewriting it in Haskell (of any size) is a good idea to actually understand the code. Please, could you do it. /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@h

Re: [Haskell-cafe] Re: Practise fingerspelling with Haskell! (Code cleanup request)

2007-07-22 Thread Mirko Rahn
the library documentation states it very clearly. /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Practise fingerspelling with Haskell! (Code cleanup request)

2007-07-19 Thread Mirko Rahn
| x == y = diff g f xs ys | otherwise=f xs ys diff g _xs ys = g xs ys diff_eq_0 :: Eq a => [a] -> [a] -> Bool diff_eq_0 = diff (\ u v -> null u && null v) (const . const $ False) /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- ---

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread Mirko Rahn
rks for infinite lists, btw. /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Construct all possible trees

2007-06-14 Thread Mirko Rahn
gt;= \ (l,r) -> [ Branch a b | a <- the_trees l, b <- the_trees r ] nonempty_splits (x:y:ys) = ([x],y:ys) : [ (x:l,r) | (l,r) <- nonempty_splits (y:ys) ] nonempty_splits _= [] /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://l

Re: [Haskell-cafe] Construct all possible trees

2007-06-13 Thread Mirko Rahn
the correction even three times). As a consequence my version is faster and eats less memory. /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://w

Re: [Haskell-cafe] Re: Construct all possible trees

2007-06-13 Thread Mirko Rahn
nch (Leaf 3) (Branch (Branch (Leaf 2) (Leaf 1)) (Branch (Leaf 4) (Leaf 5))) So please, what's going on here? -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.o

Re: [Haskell-cafe] Construct all possible trees

2007-06-13 Thread Mirko Rahn
, b <- insert x part] all_trees [] = [] all_trees (x:xs) = let this = Leaf x more = all_trees xs in this : more ++ concatMap (insert this) more /BR -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de

Re: [Haskell-cafe] Re: Slower with ByteStrings?

2007-05-29 Thread Mirko Rahn
s _ v = Just (v-1) upd m y = case Map.updateLookupWithKey ins y m of (Nothing,_ ) -> mzero (_ ,m') -> return m' in not . null . foldM upd mx Thanks for your time, BR, -- -- Mirko Rahn -- Te

Re: [Haskell-cafe] Re: Slower with ByteStrings?

2007-05-29 Thread Mirko Rahn
s) = del_acc (x:v) xs super u = not . null . foldM (flip del) u main = interact $ unlines . filter ("ubuntu" `super`) . lines BR, -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe ma

Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Mirko Rahn
! Correct (and more natural): nOf 0 _ = [[]] nOf n (x:xs) = map (x:) (nOf (n-1) xs) ++ nOf n xs nOf _ [] = [] BR, -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe

Re: [Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

2007-05-21 Thread Mirko Rahn
lso preserves sorting) ...but is exponentially slower than necessary, and fails on infinite lists. Try this one: sublistsN 0 _ = [[]] sublistsN n (x:xs) = map (x:) (sublistsN (n-1) xs) ++ sublistsN n xs sublistsN _ _ = [] triples = sublistsN 3 BR, -- -- Mirko Rahn -- Tel +49

Re: [Haskell-cafe] How Albus Dumbledore would sell Haskell

2007-04-20 Thread Mirko Rahn
va solution; but do you expect them to understand Haskell?) Add 1: This statement contradicts your "easyness" claim!? Add 2: In contrast, the Haskell solution does'nt uses "advanced Haskell features" (whatever this might be), it consists of 6 lines of plain Haskell 9

Re: [Haskell-cafe] How Albus Dumbledore would sell Haskell

2007-04-19 Thread Mirko Rahn
of mirror and rel are the same as before. Try this in your favorite language! Regards, -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Algorithms

2007-03-19 Thread Mirko Rahn
A. understand the problem B. decompose or reduce it into subproblems C. solve the subproblems D. compose a solution from the sub-solutions -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing

Re: [Haskell-cafe] FFI basics

2007-02-16 Thread Mirko Rahn
constructed function. Regards, -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- module Main where import System.Posix.DynamicLinker as DL import System.Process ( runInteractiveProcess , waitForProcess ) import Foreign.C ( CString , withCString ) import Foreign ( FunPtr

Re: [Haskell-cafe] Combinations

2006-06-06 Thread Mirko Rahn
xss) = [ x:y | x <- xs, y <- combinations xss ] BTW, I think 'cross_many' would be a better name. -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org htt

Re: [Haskell-cafe] GetOpt

2006-05-02 Thread Mirko Rahn
error prone. In contrast the sum-type technique first reads all options and then post-processes the complete set. Here the order of options on the commandline has no impact on the final result. Regards, Mirko Rahn -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http:/

Re: [Haskell-cafe] GetOpt

2006-04-27 Thread Mirko Rahn
topic several times and came up with a solution that works for me but is far from being perfect. It uses existentials and a main disadvantage is the need of explicit traversing. Moreover some new boilerplate code is necessary. You can find the interface in http://liinwww.ira.uka.de/~rahn/src/

[Haskell-cafe] List of instantiated types

2006-03-30 Thread Mirko Rahn
t)) What is the general problem? Thanks, MR [1] http://www.haskell.org/pipermail/haskell-cafe/2006-March/014947.html -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ --- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe