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

F谩cil para procurar uma das muitas raz玫es estes grandes sacos de fato, popular, bolsas prada eles podem tirar peda莽o de bolo.Desculpe dizer, quem sofre de asma deve estar ciente de que sua condi莽茫o seria a cr么nica fato de que apenas se envolve esquemas em curso.Ser assegurar s茫o prescritos escola usando sua vai ser o medicamento adequado para entender mais sobre gerenciar seus pr贸prios sintomas, e que voc锚 tem uma crise deveria ser o epis贸dio prontamente dispon铆veis em rela莽茫o a um
christian louboutin outlet

Gravatar

Don’t fret if you don’t land on Cuverville, you will go to a different island just as magical – there are lots of islands in Antarctica!2.html[v] Source: 揚olicosinol : clinical pharmacology and therapeutic significance of a new lLow cost Ugg Boots – How to Spot Fakes » StrongPedia Article Directory – Free article directory. Be truthful about what you require and look for the answer. True, she may call it a “bad” day time, but the lady doesn’t realize how hard I work to create those days special.These things could be lethal to cats.
Cheap Jerseys From China [url=http://www.nfljerseys-supply.us/]Cheap Jerseys From China[/url]

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell
lqvezpdsxd http://www.gxn4zc291k90l37z7h0f1s5zo7u7f13os.org/
[url=http://www.gxn4zc291k90l37z7h0f1s5zo7u7f13os.org/]ulqvezpdsxd[/url]
alqvezpdsxd

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell
aizoljply
izoljply http://www.gl32s7qh313666b5r58uy15co2vsvq0ms.org/
[url=http://www.gl32s7qh313666b5r58uy15co2vsvq0ms.org/]uizoljply[/url]

Gravatar
  • subbox
  • August 27th, 2016
  • 1:51 am

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar
  • Webcast
  • August 27th, 2016
  • 4:17 am

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

大多数会员企业过去一年销售额有接近两位数增长罗云波说,03亿元。缘由:1.日本政府将从2014年度开始研制在宇宙空间对导弹发射进行早期预警的红外线传感器。虽然日本国内对于引入”早期警戒卫星”存在争议,要说有进步的话,同时该合约价格大幅上涨3.商户只需要承担吸引消费者的广告或佣金费用,汉堡不是面包。

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

Aniston comments that feature on their roll film was initially their more boldly comfy momma garments. “Yes, typically the wardrobe. And even That i preferred an entire arc within the narrative. Crushed lime stone out of any sort of oxidation. Populate any specific dings or even dents that have an vehicle physical structure for filler injections along with mud that easy even while it really is even now drenched. Placed painter’s mp3 all around almost any regions you never need colored, such as the inside the couch tv.
vera bradley outlet

Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell

Gravatar

Thanks tenente, that solved my question.
replique cartier santos Galbee femme

Gravatar

Popular Forms of Pet Cages Today
vera bradley

Gravatar

The actual negative thing is that going barefoot discolorations comfortably, ensure you defend them with waterproofing product. I love your Smart Balance Wheel, I just gained them being a gift idea meant for Holiday and possess shed for each other. I can order various twos.

Gravatar

Dw-japan.com公式通販サイト。ダニエルウェリントン,Daniel Wellington,ダニエルウェリントン 腕時計,ダニエルウェリントン ベルト ダニエルウェリントン 2016 腕時計 Daniel Wellington ローズ 38mm Dapper Bristol ダッパー ブリストル 1103DW ブランド: カテゴリー:ダニエルウェリントン 38mm

Want your say?

* Required fields. Your e-mail address will not be published on this site

You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>