Skip to content
jovanhan2 edited this page Nov 17, 2018 · 14 revisions

Hourly Log

Research

  • Different ways to look at hints/heuristics
  • Semantic VS Syntax Errors
  • Deterministic, Stlystic, Heuristic

Implementation

  • Starting analyzer
  • F# Hints
  • Errors -> F# Compiler service -> Analyser -> nice pop up
  • Fold, map and reduce
  • Record own learning
  • Use only functional language
  • Tom Clarke F# course, 1 ,2 ,3
    • Exclude lamda calculus, combinators & assessed work
  • collect is same as map but will concatenate the results into a list that may be longer than the initial list GOAL: Combine with Ionide. Otherwise standalone extension together with Ionide

Learning examples

let retainPositive lst = List.collect (fun a -> if a > 0 then a else []) lst
    retainPositive [ 1; -2; -4; 0; 11] // should return [1; 11]
  • recording types of the function output and check if they are correct. - Ionide already somewhat does this?
let intList = [1..5]
let makePairs a0 = List.map (fun b -> (a0,b)) intList
let pairList = List.collect makePairs intList
// Use anon functions to avoid baked in values
let makePairs a0 = fun lst -> List.map (fun b -> (a0,b)) lst
let pairList = fun lst -> List.collect (fun a0 -> makePairs a0 lst) lst

Partially applied functions:

Think about which one will be most likely be (partially applied)[https://intranet.ee.ic.ac.uk/t.clarke/hlp/tutor1/A7.html] must be written as the first parameter

let intList = [1..5]
let makePairs lst = fun a -> List.map (fun x -> (a,x)) lst 
let pairList = List.map (makePairs intList) intList
printfn "%A" pairList
let square (x) =
    x*x
let makeTriple (a,b) = (square(a) - square(b),2 * a * b,square(a) + square(b)) 
let tripleList = List.map makeTriple pairList

printfn doesn't print, only outputs error?

let pairList = List.collect (fun a -> List.map (fun b -> (a,b)) [1..5]) [1..5]
let makeTriple (a,b) =
    let sq x = x*x
    (sq a - sq b, 2*a*b, sq a + sq b)
let tripleList = List.map makeTriple pairList
printfn "Triples are:%A" tripleList
System.Console.ReadLine() // prevent the program from terminating in Visual Studio

// versus

// this code is clever but not as easy to read as when makePairs is named
let pairListFn = fun lst -> List.collect (fun a -> List.map (fun x -> (a,x)) lst) lst
let makeTriple (a,b) =
    let sq x = x*x
    (sq a - sq b, 2*a*b, sq a + sq b)
let tripleList = List.map makeTriple (pairListFn [1..5])
printfn "Triples are:%A" tripleList
System.Console.ReadLine() // prevent the program from terminating

FSharp Questions

Dictionary

  • Linting is the process of running a program that will analyse code for potential errors.

Clone this wiki locally