16 Matching Annotations
  1. Sep 2026
    1. Exercise What other functions called in the JavaScript code generated for the above definition of main are curried? Why?

      add x y = x + y

      Currying allows a function to receive arguments one at a time, which enables partial application and makes functions eaiser to reuse and compose

    2. in Haskell, putting the argument after the function left-to-right unless operators change the grouping

      replace every $ with brackets main = log $ show $ map fibs $ 1..10 equivalent to main = log (show (map fibs (1..10)))

      map fibs (1..10) apply fibs to every number in the list

    3. pattern matchingA mechanism in functional programming languages to check a value against a pattern and to deconstruct data. ,

      fibs 0 = 1 ^ ^ ^ | | | | | result | pattern function

      Haskell commonly uses pattern matching instead of writing if/else for cases where the input's structure or value determines what to do.

    1. An essential thing to know before trying to type in the above function is that Haskell delimits the scope of multi-line function definitions (and all multiline expressions) with indentation

      Haskell uses indentation to know which lines belong to a block code

    2. () (called unitA type with exactly one value, (), used to indicate the absence of meaningful return value, similar to void in other languages. )

      void in Java / C / TypeScript

    1. REQ1 Heath points (HP) = hit point which is in Farmer constructor

      GameEntity class is used to control the actor's statistic

      unconscious(map) removes the Farmer from the map

    1. High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend upon details. Details should depend on abstractions.

      Depend on abstractions rather than concrete implementation

    1. Liskov Substitution Principle

      A child/subclass should be able to replace its parent/superclass without breaking the program's expected behaviour.