Search code examples
functional-programmingjvm-languages

What is a good use case to implement for learning Functional Programming?


I am a Java programmer looking to learn Functional Programming. My aim is to implement a simple use case (say a simple text-based game like tic-tac-toe) in various Functional Programming languages (i.e. Clojure, Scala) in order to learn the ins and outs of each.

Are there any FP gurus out there who can recommend a specific use case that I could begin with? Or is Tic Tac Toe (noughts and crosses) good enough to get started?

Note that at this point I will be focusing on JVM based languages.


Solution

  • I think Tic-Tac-Toe would help you, indeed. Let me share how I started, I started learning by,

    • Writing arithmetic functions in Clojure; for example, next-prime, prime?, factors, prime-factors, and stuff like that
    • Then making those idiomatic as far as I could
    • Then ask question here, or anywhere, to improve a particular function

    Here is the link of math.arithmetic.

    Note: It's missing a decent README. I'll put that later. Actually, I never thought of sharing this because it's so trivial.

    [Edited]

    You can try 4clojure.

    4Clojure is a resource to help fledgling clojurians learn the language through interactive problems.

    [Edited, again]

    There is also Project Euler, which many people have found useful for precisely this sort of thing.

    Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve.