Approaches for Bob

As @iHiD and I will be doing some videos again, what better way to get started again than with our iconic Bob exercise. I’ve currently gathered the following solutions:

  1. Python: pre-determine states and use if-statements
    Pre-process the text and determine the various states, to be used in if statements

  2. Kotlin: extension functions
    Use extension functions

  3. SQLite: use regular expressions
    Use regular expressions to match the input

  4. Gleam: pattern matching on booleans
    Use pattern matching on the boolean values

  5. D: answer array
    Convert the states into an index into a fixed array of answers

  6. F#: custom pattern matching patterns
    Define custom pattern matching patterns via Active Patterns

  7. Prolog: grammar
    Define a grammar to solve the problem

If you know of other interesting and different solutions, please let me know.

1 Like

Pattern matching on tuples of booleans (F#) (I do kind of the same thing in awk).

1 Like

That’s very nice. Do you have another language that you do this in? F# already has an entry and I try not to repeat languages (and the AWK one is visually less striking I feel)

Elm, Gleam, Dart

1 Like

Perhaps Haskell if you think talking about guards is interesting (but this was probably covered in some other videos, if not in haskell than likely in Elixir).

Would love to see languages like Zig, Elixir, Go, Rust, and odin in there as well.

Those languages have regularly been featured. We’re definitely not opposed to including them or anything. If you can find a new type of solution in those languages I’m happy to feature them

Maybe you want to feature one of Exercism’s Top Ten languages that has not yet appeared in the series: PHP? This one uses modern idiomatic PHP for a similar approach to the Python one you chose. There is also tuple matching available.

Katrina has her talk. That goes over many solutions too!

1 Like

Do you have a link?

Apparently I do. Took me a while to find.

1 Like