Skip to Content »

online discount medstore
advair diskus for sale
buy advair diskus without prescription
allegra for sale
buy allegra without prescription
aristocort for sale
buy aristocort without prescription
astelin for sale
buy astelin without prescription
atarax for sale
buy atarax without prescription
benadryl for sale
buy benadryl without prescription
buy clarinex without prescription
clarinex for sale
buy claritin without prescription
claritin for sale
buy flonase without prescription
flonase for sale
buy ventolin without prescription
ventolin for sale
amoxil for sale
buy amoxil without prescription
augmentin for sale
buy augmentin without prescription
bactrim for sale
buy bactrim without prescription
biaxin for sale
buy biaxin without prescription
buy cipro without prescription
cipro for sale
buy cleocin without prescription
cleocin for sale
buy dexone without prescription
dexone for sale
buy flagyl without prescription
flagyl for sale
buy levaquin without prescription
levaquin for sale
buy omnicef without prescription
omnicef for sale
amaryl for sale
buy amaryl without prescription
buy cozaar without prescription
cozaar for sale
buy diabecon without prescription
diabecon for sale
buy glucophage without prescription
glucophage for sale
buy glucotrol without prescription
glucotrol for sale
buy glucovance without prescription
glucovance for sale
buy micronase without prescription
micronase for sale
buy prandin without prescription
prandin for sale
buy precose without prescription
precose for sale
buy cialis professional without prescription
cialis professional for sale
buy cialis soft without prescription
cialis soft for sale
buy cialis super active without prescription
cialis super active for sale
buy cialis without prescription
cialis for sale
buy levitra without prescription
levitra for sale
buy viagra professional without prescription
viagra professional for sale
buy viagra soft without prescription
viagra soft for sale
buy viagra super active without prescription
viagra super active for sale
buy viagra super force without prescription
viagra super force for sale
buy viagra without prescription
viagra for sale
buy celebrex without prescription
celebrex for sale
buy colcrys without prescription
colcrys for sale
buy feldene without prescription
feldene for sale
buy imitrex without prescription
imitrex for sale
buy inderal without prescription
inderal for sale
buy indocin without prescription
indocin for sale
buy naprosyn without prescription
naprosyn for sale
buy pletal without prescription
pletal for sale
buy robaxin without prescription
robaxin for sale
buy voltaren without prescription
voltaren for sale

Tech Life of Recht » Fun with Haskell

 Fun with Haskell

  • January 19th, 2007
  • 2:02 pm

At JAOO 2006, I attended a session with Erik Meijer on Haskell. The session gave a very quick introduction to Haskell as a very nice functional language, and the enthusiasm of Erik Meijer on the subject only made it more interesting.
So, I’ve been messing around with Haskell for a while, without producing anything worthwhile – I’m still trying to figure out how to put the language to good use. However, I found a list of Haskell quizzes, derived from Ruby Quiz. Some of these have not yet been solved, so I sat down and began working on Splitting the Loot. After some hours, I suddenly discovered that I have a working solution – somewhat to my surprise.

Anyways, here it is – as it’s one of my first Haskell programs, I’m sure there’s lots of room for improvement. What it does is basically to find all possible combinations of a list of numbers, and then it tries to combine these combinations in order to find a valid solution:

[code]
divide :: Integer -> [Integer] -> [(Integer, [Integer])]
divide persons vals
| toInteger (length vals) < persons = error "Not enough values" | not $ mod (sum vals) persons == 0 = error "Values cannot be divided equally" | otherwise = divide'' persons vals (div (sum vals) persons) [] 1 divide'' persons vals maxval res cnt | cnt > persons = res
| otherwise =
let p = permut vals maxval
nx = findE p maxval
in divide” persons (deleteFirstsBy (==) vals nx) maxval ((cnt, nx):res) (cnt + 1)

findE [] c = error “Unable to find fitting element”
findE xs c
| sum (head xs) == c = head xs
| otherwise = findE (tail xs) c

uniq [] sorted = reverse sorted
uniq xs [] = uniq (tail xs) [head xs]
uniq xs sorted
| head xs == head sorted = uniq (tail xs) sorted
| otherwise = uniq (tail xs) (head xs:sorted)

permut :: [Integer] -> Integer -> [[Integer]]
permut nums maxval = permut’ nums [] 0 maxval

permut’ :: [Integer] -> [[Integer]] -> Int -> Integer -> [[Integer]]
permut’ nums [] _ maxval = permut’ nums (map (\x -> [x]) nums) 0 maxval
permut’ nums xs cnt maxval
| cnt + 2 > length nums = uniq (sort xs) []
| otherwise = permut’
nums
(xs ++ uniq
(sort $
foldr (++) []
[map (\ ys -> appendIfNecessary x ys nums maxval) xs | x <- nums] ) []) (cnt + 1) maxval appendIfNecessary x xs old maxval | elem x (deleteFirstsBy (==) old xs) = if (sum xs) + x > maxval
then xs
else x:xs
| otherwise = xs
[/code]

9,920 People had this to say...

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell
vsgjhxtvnv http://www.gw2e4h94375wsjh0bk0073nzgulp1556s.org/
avsgjhxtvnv
[url=http://www.gw2e4h94375wsjh0bk0073nzgulp1556s.org/]uvsgjhxtvnv[/url]

Gravatar

The publisher has been compensated fifteenthousand dollars by Entourage Media. It is additionally a very important selection due to the fact that your particular net variety directly impacts your website’s uptime. Tend not to eliminate articles, as being the end user will probably cease after the webpage. Your changes ought to have a lot of content and have info buyers are interested in.Boxers also use mouth guards to guard their teeth from getting knocked out.

Gravatar

A boxing match amongst two girls is called foxy boxing. When you serve: Put as much backspin and or sidespin on the ball with your tacky rubber brush the ball with an action under the prior (and later for sidespin). Each and every bit of education equipment is applied to strengthen a selected part of the body or in enhancing reflexes, pace, agility, and motion. It can be probable that you just will discover the need to keep with Burst 3. There is no other strategy that works as well.

Gravatar

If you have a sunlight sparkle or even the insights within your diamond earrings. It really made an intense sense on her. Their own bodies ended up keeping up. Should i propose that Dexion racks system may be a trouble-free strategy to help to make and also retailer compared to personal computer figure? It is sometimes readily available very inexpensive or simply left.
Steph Curry 3

Gravatar

Home cures pertaining to Pet puppies Acquiring MangeMange can be quite a condition of your skin attributable to mites infesting your current pets fur.
Jigsaw Puzzles for Sale

Gravatar

hahahahaha damn suay like that cannot go in because of pain drives T_T then again i don鈥檛 know what are pen drives wtf. AND I CAN RELATE TO THE LAST ONE damn embarrassing right think got parcel turns out dont have T__T
retro jordan 1

Gravatar

The media who: a review of the history of ten points flash straight after Michael Jordan Only one active service

Gravatar

Wow! Thank you! I always wanted to write in my site some thing like that. Can I take part of your publish to my blog?
sergio rossi

Gravatar

As long as you observe the guidelines on the product package, it’s possible to correctly deep clean the car. The use of fabric for tables, chairs and wall can also be best. The particular Venue Decoration Newport service is also good for your own benefit. It would be preferable to have some practice with the bat against other players to adapt to them before you embark on your mission to “destroy the aggressors. Should your site sells pool tables, there is no explanation to obtain an advertiser that sells oven mitts.

Gravatar

GREAT subject we need to get the word to more people and fast!!!!!
replica orologi cartier tortue

Gravatar

oui pour tp,c’est uen bonne chose,meme si je crois qu’il arrete l’edf apres les jo à rio. sur le meneur allemand,il a le tir de la prolong quand meme,il a été le meilleur joueur allemand,ils sont à la maison et sont éliminés,c’est aps évident. apres la nba comme je t’ai dit,je suis surtout les plays offs,pas trop la saison régulière,donc je connais pas trop les effectif,surtout que ça bouge pas mal lol. yes plaisir partagé ça marche,à plus
cartier tank mc chronographe

Gravatar

QINGDAO RUIZHENPLANTOIL CO. LTD

Gravatar

straker heyward unplumbed furay kyuzo trammps Herbert craze tripwire
outlet barbour

Gravatar

Beijing media: guoan this season is 20 years the worst The only bright spot is to spend money

Gravatar

This is how to get your foot in the door.
belstaff sale mens

Gravatar

I have to say, I dont know if its the clashing colours or the dangerous grammar, however this weblog is hideous! I imply, I dont need to sound like a know-it-all or anything, however could you could have presumably put a little bit extra effort into this subject. Its really fascinating, but you dont signify it well at all, man. Anyway, in my language, there usually are not much good supply like t
rene caovilla london store

Gravatar

Hello. impressive job. I did not anticipate this. This is a splendid story. Thanks!
patagonia sale jackets

Gravatar

How is it that just anybody can publish a weblog and get as popular as this? Its not like youve said something incredibly impressive more like youve painted a pretty picture above an issue that you know nothing about! I dont want to sound mean, right here. But do you genuinely think that you can get away with adding some fairly pictures and not really say something?
pierre hardy sizing

Gravatar

There are various kinds of yoga. These are really different from boxing matches among men. Well, if you’ve been on receipt of such abuse, this guide May be just for you. Nevertheless, recently the CompTIA A+ certification program of has undergone a revision soon after careful scrutiny and research, and new technologies like SD enjoying cards, Bluray, Television tuner cards, Bluetooth, DDR3, House windows 2000, Windows XP and Dwelling windows Vista have already been incorporated. Fantastic organizations will give that data to their affiliates, plus they can utilize it to promote additional and make extra.

Gravatar

When I go to Clip Art in Word it says it is no longer available. Previously it had been removed and was sending you to Bing images. Can you explain how you are able to access Clip Art gallery in Word now? Thank you
bracelets love cartier imitation

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

Walton hailed super subs: he is this lakers team manu ginobili