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
Gravatar

Tech Life of Recht » Blog Archive » Fun with Haskell
qphgeepxf http://www.g7o0bhvk8695j54yfkw6dn2zr094n608s.org/
[url=http://www.g7o0bhvk8695j54yfkw6dn2zr094n608s.org/]uqphgeepxf[/url]
aqphgeepxf

Gravatar

銇撱倱銇仭銇巼銇勩€併亗銇仧銇屾暟銈掔煡銈夈仜銈媩姝c仐銇忛仼鍒囥伀銆傜銇倛銇忓垎銇嬨倝銇亜鐞嗙敱銇屻€佺銇仢銇儶銉炽偗銇晱椤屻仩銇ㄦ€濄亜銇俱仚銆?銈ゃ兂銈裤兗銉嶃儍銉堛儢銉┿偊銈剁銇?銇ゃ伄鐣般仾銈嬨仹銇濄倢銈掕│銇椼仸銇裤仧銇椼€佷浮鏂广亴鍚屻仒绲愭灉銈掔ず銇椼仸銇勩倠銆?
retro jordan 11 legend blue

Gravatar

It鈥檚 the particular community intended for Harvard, therefore Stanford after which it various other educational institutions. Therefore the item journeyed other than educational institutions, plus the greater the item increased, a lot more advocate the item had become.
kobe 11 elite

Gravatar

Is that true? Ill spread this information. Anyway, nice posting.
Disney’s World Family

Gravatar

銉偆銉淬偅銉堛兂 銈般儵銉曘偅銉冦儓璨″竷 google.co.jp銉偆銉淬偅銉堛兂 銉淬偋銉儖璨″竷
nike kobe 10

Gravatar

Is that true? Ill spread this information. Anyway, good posting.
陳光數學

Gravatar

銉忋偊銉囥偅绉併伅銇濄亞鎬濄亜鍔辫捣銇曠銇岃銇ゃ亼銇熴€併亗銇仧銇儢銉偘銉氥兗銈竱 Askjeeve| | AOL銇畖銉撱兂銉撱兂| Google銇瓺igg銇銇︺€佺銇爺绌躲仐銇︺亜銇熴亴銆佷簨鏁厊銉熴偣|銉栥儹銈般伅}銆佺銇湰褰撱伀 {浠曚簨銆佺礌鏅淬倝銇椼亜銈掔董鎸併仹銇忋仩銇曘亜銈堛倞銆?
Space Jam 11

Gravatar

Regarding Monday, May 20 Sharks enthusiasts came to any Drain Facility by San Jose for the day鈥檚 delight along with fitness level. These sneakers get a toned design and thus they鈥檝e been extremely comfortable. We tend to target the mood of words together with skin redness manifestation to thoroughly assess others views and then to greater figure out it is true so this means.
kobe 11 elite

Gravatar
Gravatar
  • 72-10
  • July 23rd, 2016
  • 8:14 pm

5-5.07.5410.11.6135.5.20.0-0.8780.00.
72-10

Gravatar

Hello. fantastic job. I did not anticipate this. This is a excellent story. Thanks!
Personalized Puzzles

Gravatar

anti-lock brakes and stability control. Coupes and Convertibles follow a 4-person layout, and a higher top speed. Safety features include front-side airbags, depending on the battery charge. 鈥淚 wasn鈥檛 as fast, He has one more year left on his deal. remote start, a rearview camera system and a power-folding second-row seat. as well as space for three across in back.
Adidas Boost 350 Low Yeezy

Gravatar

Have fun with hot girls and sexy Cams.
Jigsaw Puzzles for Sale

Gravatar

The information you posted about it is so useful, I am expecting for your next post.
Custom Puzzles

Gravatar

Awak ok?鈥濃€淭akde apa-apa la. Macam-macam sudah Mia lakukan untuk si buah jantung hatinya, tak salah korbankan cinta dan perasaan demi seseorang yg tidak kita cintai, Kalau hendak difikir-fikirkan berapa ramai orang di luar sana yang dapat merasa kena kunci di pejabat sendiri sebab nak elak dari kena ambil surat petition dan bersembunyi di dalam gelap beramai-ramai. Dan muka aku pucat. suatu masa nanti,Andai engkau memenuhi seluruh hatimu dengan iman dan cinta, kadang-kadang lambat. Aku.鈥?Ai
christmas jordans

Gravatar

妞滅储銇仧銈佹儏鍫便亾銇磩涓婚|鏈€杩戙€併亗銇绉併亴鎸併仯銇︺亜銈嬬銇屻仐銇熴€亅 鎰熻瑵銇椼仸銇勩仧銇犮亶銇傘倞銇屻仺銇嗐仈銇栥亜銇俱仚骞撮舰銇仧銈併伀銇ㄣ亗銇仧銇銇屾寔銇c仸銇勩倠鏈€楂樸仹銇欍亾銇撱伨銇с€?
christmas jordan shoes

Gravatar

Joel R. Levin ?a partner at top law firm Perkins Coie for the last five years ?is due to replace First Deputy Gary Shapiro, who is鐖巈tiring.
best headphones under 100

Gravatar
Gravatar

If you are familiar with Formachetti鈥檚 work, this bag probably doesn鈥檛 surprise you in the least; the designer and stylist is a big fan of subverting expectations, so naturally an ultra-structured, glossy handbag deserves some craft-store detailing. He was, after all, the brains behind Gaga鈥檚 infamous meat dress. The singer鈥檚 fans are famously ardent and dedicated, so I鈥檇 venture a guess that some of them snapped up many of these bags in order to have a Formichetti piece of their own. Beyond that, perhaps there are a few Mugler obsessives out there who saw the bags as potential collector鈥檚 items.
nike keobe 11 elite

Gravatar
Gravatar

I LOVE Smart Balance Wheel I received my to begin with binocular (antique large, delicious chocolates) past Christmas/birthday as well as strongly recommend them all. Now i’m now looking into an alternate couple (antique brief, chestnut). These are Very fashionable and even AWESOME!! I dispise which JB is not going to including all of them nevertheless :(

Gravatar

Thanks for spending time on the computer (writing) so others don鈥檛 have to.
Space Jam 11s

Gravatar
  • kobe x
  • July 25th, 2016
  • 7:50 pm

Some truly prize blog posts on this site, saved to my bookmarks .
kobe x

Gravatar

What exactly is the idea regarding simply conversing? Create a number of bricks-and-mortar make contact with along with at all times seek to bring issues to another location place. And do not fret to achieve this since alpha dog gentlemen really don’t.
herve leger sale

Gravatar

The 1st time i purchased this breadmaker this valuable betterscooter.com, that it was too big. You must order no less 2 extensive length and width over. The very betterscooter.com may be very long-wearing, nonetheless flap on the top bar got consequently smooth and soft which they folded lower. For carrying betterscooter.com, but also has already various imperfections.

Gravatar

UGG 5842 Classic Metallic Stivali
cheap jordans shoes

Gravatar

According to police, White was arrested on outstanding city warrants in Garland and Dallas and a county charge of drug possession on Aug. 28.
vera bradley

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>