top of page
Stupid marcel tricks

Compute 100!

  • gen 100 1: Generates 100 integers starting with 1.

  • red *: Reduce using multiplication.

Screenshot from 2020-06-15 21-34-52.png

Distribution of word lengths

  • cat /usr/share/dict/words: Generate a stream of words, from /usr/share/dict/words. This uses the host executable cat.

  • map (w: (len(w), 1)): For each input word, generate an output tuple containing the length of the word and the number 1.

  • red . +: Group by word length, and sum up the 1s.

  • Sort the tuples.

Screenshot from 2020-06-16 17-31-50.png


Marcel can be used as a calculator, by writing an expression inside parentheses. The command below computes the golden ratio. It is equivalent to using the map operator with a zero-function argument, i.e. map (lambda: (1 + sqrt(5)) / 2).

Screenshot from 2020-06-16 17-51-35.png


A traditional "low bar" job interview question is to implement FizzBuzz: For the integers 1 through 100, print Fizz if the number is divisible by 3, Buzz if divisible by 5, FizzBuzz if divisible by both, and the

number itself otherwise. Here it is as a marcel command:

Screenshot from 2020-06-25 14-49-19.png
bottom of page