Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Basic of Haskell 101. Chapter 2.
Brain Dump
Sep 6, 2024
88 views
1. Function Definition:
Functions are defined using equations:
2. Function Application:
means apply function f to arguments x & y
3. List Basics
4. The cons operator (:)
adds an element to the front of a list:
5. Pattern Matching:
Uses pattern matching for function definitions:
6. Guards:
Guards are ways to define functions based on conditions. They allow you to test properties of the function's arguments and choose the appropriate function body based on those tests.
How this works?
7. Where & Let
These are used for local definitions. These allows us to create intermediate values or helper functions that are only used within a specific function.
These where definitions are visible throughout the entire function body, even before they're defined.
the let...in expression in Haskell is a way to define local variables or functions that are only used in specific part of the code.
8. Higher Order Functions:
Functions that takes other functions as arguments.
foldr:
foldr works by applying the given function to each elements of the list, starting from the right to left.
The accumulator is a value that's carried along as foldr process the list. It stores intermediate result of the computation.
9. Lambda functions:
Anonymous functions, that are defined without being bound to an identifier. Called lamba functions because of their origins in lambda calculus.
More examples of lambda fucntions:
using lambda in higher order functions
Lambda function that uses pattern matching:
10. Type Declarations:
You can explicitly declare types
11. List Comprehension:
Some more examples of list comprehension:
12. Currying
All function in Haskell are curried by default.
13. keywords
how to use Maybe?
For example of finding 2nd element in the list.
14. List Indexing Operator:
!!, is used for list indexing.
#haskell #basicSyntax #programmingLanguage #functionalProgramming