I have started learning F# again, thanks to @isaac_abraham and his great presentation in my company. This time hopefully, I will move past the “WTF”, barrier and move to “AHA” moment. I am ready to finally start serious F# learning with couple of milestones like: project euler, tool, web-app, complex project. I will try to document whole process on the blog. I want to force myself and learn new functional paradigm. Hopefully it will give me a new way to look at problems and solutions for them. To this day I have spent most of the time in OO world, meh, it gets boring, really. I might also get a chance to do something cool with F# for my company. Me and 3 of my coworkers, we are trying to explore together DDD with F# and find a better way to model our code/ To start somewhere, I was given a link to a great site with a list of advices http://fsharpforfunandprofit.com/learning-fsharp/ Do’s and Don’ts section is very helpful. You can consider this as “House rules” constraining you with a form of “force yourself to think differently”.
Project Eueler 1 As usual, when I don’t know where to start with new language I go to
Project Euler site. I am thinking about doing 10 problems just to get a hold on the syntax and features.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. The first problem it’s not that hard. You can do it by a brute force loop. there is also a better solutions that has lower complexity. My solution is just a loop.
I like the syntax, it looks really nice. 1st : I am declaring new function ‘ismultiplier’. 2nd : I am creating a sequence with filter in form of if. From my understating sequence is similar concept to a loop over some elements but its being lazy loaded. The data is created on the fly, while code iterates through it. 3rd : I am using Seq method to sum up the yielded values. This is a simple algorithm, it won’t be enough to learn F# properly. That’s when some practical project will come in. It’s still planned, I have couple of ideas. It has to be something useful and complex enough project so can I learn how to structure code properly and how to use OOP inside F# world.
@ScottWlaschin - his great presentation convinced me even more that F# is the language I WANT to learn. @isaac_abraham - F# MVP, Issac’s presentation create first ripple that forced me to consider F# again. @eulerfx
Railway Oriented Programming - unfortunately there is no direct link Domain Driven Design, F# and Types - Beautifully explained how you can leverage F# to model your domain. Domain-Driven Design, Event Sourcing and CQRS with F# and EventStore