![]() The lists within a list can be of different lengths but they can’t be of different types. If you want to get an element out of a list by index, use !!.Putting something at the beginning of a list using the : operator (also called the cons operator) is instantaneous.This is done by using the ++ operator. When you put together two lists internally, Haskell has to walk through the whole list on the left side of ++. But putting something at the end of a list that’s fifty million entries long is going to take a while. ![]() A common task is putting two lists together.It stores several elements of the same type. In Haskell, lists are a homogenous data structure.Functions can’t begin with uppercase letters.We usually use ‘ to either denote a strict version of a function (one that isn’t lazy) or a slightly modified version of a function or a variable. It’s a valid character to use in a function name. That apostrophe doesn’t have any special meaning in Haskell’s syntax.The difference between Haskell’s if statement and if statements in imperative languages is that the else part is mandatory in Haskell.Function application (calling a function by putting a space after it and then typing out the parameters) has the highest precedence of them all.When you compile your program, the compiler knows which piece of code is a number, which is a string and so on. That means that unless specifically told otherwise, Haskell won’t execute functions and calculate things until it’s really forced to show you a result. Haskell is a purely functional programming language. You can’t set a variable to something and then set it to something else later: a function has no side-effects.Learn you a Haskell for great good cheat-sheet It doesn’t contain the code block and I highly recommend you to read the book but its good to have a source where you can read a line or two about a concept by doing a quick search on a single web page. It basically try to pack in 40 pages the content of 400 page book. This blog can work as a cheat sheet for a quick look about a concept. So this blog contains all the important things I read about Haskell in that book. I have a habit of preparing notes for anything important I read. So for past 20 days I have been reading Haskell. It a really good book with a version available free online. Therefore I decided to read a book about Haskell first, called Learn You a Haskell for Great Good!. ![]() I had no clue, how to write a code all functional. ![]() However, I couldn’t find courage to do the same for Haskell. I was all set to get my hands dirty by starting to write swift code following learn by doing philosophy. Also, I have been hearing a lot of buzz related to functional programming recently. I chose Swift because of its super hackable nature, allowing us to change properties of the language on the fundamental level and Haskell because, well I thought doing differential programming in a functional programming language will be cool. So, I settled on Swift and Haskell to write my own Deep Learning model ( maybe a library one day). I thought that it will be a good opportunity for me to write my model in a language that I have never used before. Writing our own highly optimized deep learning models can be a complex task as it involves a really good understanding of a lot of programming fundamentals specially when it comes to optimization. However, I wanted to write my own algorithm and see if it can stand a chance of beating the state-of-art results. I was able to get a state-of-art results using algorithm like EfficientNet and using FastAI framework. For past several months I have been working on an image classification problem. ![]()
0 Comments
Leave a Reply. |