Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# advanced exercises

I've finished reading books on F# and I've done most of the exercises in the book which were kind of basic. Now I'm looking for more advanced exercises to improve my skills with the language and functional programming concepts in general.

Is there a place or a book where I can practice F# with specially designed exercises to learn the language features? Right now I've only managed to find introductory stuff or general programming problems websites (for example Project Euler).

My goal is really to learn how to think in a functional way and get used to things like pattern matching, partially applied function, monads/workflows, tail recursion, and so on. I want to learn how to solve problems using functional constructs.

I'd be also interested in any good exercises that were designed for other functional programming languages (like Haskell).

like image 373
foobarcode Avatar asked Feb 06 '13 20:02

foobarcode


4 Answers

If you believe in learning through hand-on experience, Project Euler problems may be the exercises for you. They are not limited to functional programming but their mathematical nature is well-suited to F# and other functional languages. Yet Another Project Euler Series is a good resource to get started with Project Euler in F#.

I used to learn Prolog through 99 problems but I saw people learn Lisp, Haskell, OCaml, etc through them as well. I think these exercises are useful resources to learn F#. They are well-designed problems. The first few ones teach you to work with lists (basic data structure in F#). More advanced problems on logic, tree and graph are good opportunities to explore advanced F# features. Here are the sets of solutions in OCaml and F# in case you need them for reference.

like image 116
pad Avatar answered Nov 18 '22 20:11

pad


I got started by going through the first 50 Project Euler problems. That was a great initial learning experience.

Soon after I started participating actively on Stackoverflow F# tag. Seeing the answers provided by others, and having to research answers of my own was very educational (you know what they say about learning by teaching, it's true).

Then my greatest learning experience came from work on open source projects in F#. Namely FsEye and Unquote. Both of those ideas came from reflecting on my experience with F# and seeing what opportunities existed for enriching the F# ecosystem. In the case of FsEye, it was enhancing the FSI experience. In the case of Unquote, it was exploiting a unique F# feature. These two learning by doing experiences on serious projects were what really brought me to a point of deep understanding and skill in F#.

like image 28
Stephen Swensen Avatar answered Nov 18 '22 19:11

Stephen Swensen


tryfsharp.org is a great site for learning F#. Tutorials are broken down by skill level and problem domain. It might be just what you're looking for.

like image 7
Daniel Avatar answered Nov 18 '22 19:11

Daniel


HackerRank provides you with algorithmic challenges. There is a whole section devoted to functional programming and when you create a solution you can select F# as your language of choice.

Within functional programming you can select among different task groups: recursion, functional structers, parsers, to name a few.

like image 4
PiotrWolkowski Avatar answered Nov 18 '22 19:11

PiotrWolkowski