# My Racket page: Project Euler problems 1..50 and a lot of Gamble probabilistic programming models

**URL:** <https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180>\
**Category:** Show & Tell\
**Created:** [September 26, 2024, 5:52pm UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180 "2024-09-26T17:52:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hakank/32/1838_2.png) [@hakank](https://racket.discourse.group/u/hakank)\
**Post date:** [September 26, 2024, 5:52pm UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/1 "2024-09-26T17:52:54Z")

</div>

(I'm still a little embarrassed about my newbie question earlier, but nowadays I only focus on Racket and don't mix with other Lisps, except for Emacs Lisp occasionally. I still do newbie mistakes, but not very often that one. :-)).

I really like Racket, mostly for its extensive support of a lot of nice packages, e.g. math and Gamble. Perhaps my style is not the purest style, since I tend to prefer for loops over recursion for traditional loop stuff.

Here is my Racket page: [My Racket page](http://hakank.org/racket/) .  
The programs are also at my GitHub repo: [hakank/racket at master · hakank/hakank · GitHub](https://github.com/hakank/hakank/tree/master/racket) (I try to keep this as updated as possible, but there might be some lag).

The page includes:

- The first 50 Project Euler problems ([https://projecteuler.net/](https://projecteuler.net/) )  
Whenever I start learning a programming languages, this is one of the first things I do.  
Happily Racket's math packages includes a lot of nifty and fast functions which makes this one of the fastest runs, about 2.7s solving time for all problems. (See [My Project Euler page](http://hakank.org/project_euler/) for comparison with my other Project Euler programs. )

- And then the Gamble probabilistic programming package, what a great tool!

Working with Gamble is so fun so I have not yet explored the Racket language in full, so that is on my TODO list, as well as checking out some other interesting packages such as racklog, minikanren, csp, Rosette,

By the way, I'm a (retired) Swedish software developer. Nowadays I'm an Independent Researcher, mostly in Constraint Programming, logic programming, and Prolog. Here's my site: [http://hakank.org/](http://hakank.org/) .

---

<div class="post-metadata">

**Author:** ![jay\_bird](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@jay\_bird](https://racket.discourse.group/u/jay_bird)\
**Post date:** [December 2, 2024, 11:42pm UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/2 "2024-12-02T23:42:30Z")

</div>

I appreciated this post, even though I'm new to Racket and don't know many of the things you refer to.

I was curious about Gamble in particular, as I've been doing a bit of probability recently, but had to go click around a bit before getting to the main thing, so here's the link to the relevant book for anyone in the same boat:

[https://rmculpepper.github.io/gamble/index.html](https://rmculpepper.github.io/gamble/index.html)

It looks nice! But maybe `scribble` just looks nice, hah. Did you go through the book, or just jump in to using Gamble? Was the fact it is discontinued relevant, or did everything work well?

I could conceivably use it to play with models of the problems I'll do if I continue with the probability book I have been investigating. It'd certainly be a good excuse to attempt some racketeering.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hakank/32/1838_2.png) [@hakank](https://racket.discourse.group/u/hakank)\
**Post date:** [December 3, 2024, 4:51pm UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/3 "2024-12-03T16:51:27Z")

</div>

I have written quite a few probabilistic programming language (PPL) programs before (e.g. in WebPPL, see my WebPPL page: [My WebPPL page](http://www.hakank.org/webppl/) ) and started to port these to Gamble. Since I knew what I wanted to do, but didn't know the exact syntax, I just browsed the Gamble docs randomly, especially the "Probability Distributions" and "Samplers and Solvers" pages. Eventually, I've read the complete Gamble book, but not in sequel.

However, since I was used to a specific representation of the output (from WebPPL), I had to write quite a few helper functions, for example the main wrapper function `show-marginals` (defined in [http://hakank.org/racket/gamble\_utils.rkt](http://hakank.org/racket/gamble_utils.rkt)) that shows the model output similar(ish) to WebPPL's output.

It's of course a pity that Gamble has been discontinued, but I've found very few things that didn't work as expected and that couldn't be fixed (worked around) somehow. That being said, an updated version of Gamble would probably contain different/faster sampler/solvers.

By the way, WebPPL is also discontinued, but it's still one of my favorite PPL, now together with Gamble.

A really great book for beginners in Probabilistic Programming is "Probabilistic Models of Cognition" [http://probmods.org/](http://probmods.org/), which happens to showcase WebPPL (and is written by the WebPPL creators).

---

<div class="post-metadata">

**Author:** ![jay\_bird](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@jay\_bird](https://racket.discourse.group/u/jay_bird)\
**Post date:** [December 6, 2024, 1:49am UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/4 "2024-12-06T01:49:40Z")

</div>

Noted, bookmarked, and thank you for sharing your experiences - that book looks very interesting!

---

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://racket.discourse.group/u/AlexG)\
**Post date:** [December 13, 2024, 2:00pm UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/5 "2024-12-13T14:00:09Z")

</div>

Nice to see fellow Racket newbies with a view to a good scientific future for Racket! BTW, picat is still very high up my list of constraint languages to explore - I'm battling with CHR at the moment.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hakank/32/1838_2.png) [@hakank](https://racket.discourse.group/u/hakank)\
**Post date:** [December 16, 2024, 4:35am UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/6 "2024-12-16T04:35:12Z")

</div>

Have you tested Racket's SMT constraint model package Rosette ([The Rosette Guide](https://docs.racket-lang.org/rosette-guide/index.html) )?

---

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://racket.discourse.group/u/AlexG)\
**Post date:** [December 17, 2024, 4:24pm UTC](https://racket.discourse.group/t/my-racket-page-project-euler-problems-1-50-and-a-lot-of-gamble-probabilistic-programming-models/3180/7 "2024-12-17T16:24:15Z")

</div>

Looks fascinating, but it will be a while till I get round to it 🙂
