This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { | |
AsyncStorage, | |
View, | |
TextInput, | |
Picker, | |
Text, | |
Button | |
} from "react-native"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
replace with : (String , String , String) -> String | |
x replace y with z = | |
'a List :> nil | |
'a List :> 'a head ; 'a | |
x = 1 head ; 1 ; 2 ; 3 ; 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xs = [1,2,3,4,5,6,7,8,9,10] | |
// Q1. Take only the number that is more than 5 | |
// Q2. Multiply each number by 5 | |
// Q3. Add all numbers together | |
let people = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Endpoint } from "../../src/lib/DiloServer"; | |
/** | |
* Common response code | |
* 401 - Request body error | |
* 500 - Internal server error | |
*/ | |
const LIST_OF_PERMISSIONS = { | |
"1100": true, // User management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NULL | |
Circle 5 | |
Rectangle 3 4 | |
Circle 3 | |
Rectangle 8 1 | |
Square 5 | |
NULL | |
Rectangle 6 0 | |
NULL | |
Square 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map.Strict as Map | |
import Data.List | |
-- This implementation is based on https://medium.com/@dhruvrajvanshi/type-inference-for-beginners-part-1-3e0a5be98a4b | |
data Expression | |
= EInt | |
Int -- value | |
| EVar | |
String -- name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Shape | |
= Circle Float | |
| Square Float | |
| Rectangle Float Float | |
| Null | |
deriving (Show) | |
main :: IO () | |
main = do | |
-- Read contents from shape.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Shape {} | |
class Circle extends Shape { | |
constructor(public radius: number) {} | |
} | |
class Rectangle extends Shape { | |
construtor(public height: number, public width: number) {} | |
} | |
class Triangle extends Shape { | |
constructor(public height: number, public base: number) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const newShape2: Shape = { | |
label: 'circle', | |
width: 30 // You'll get a compiler error saying `width` does not exists when label is `circle` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getArea = (shape: Shape) => { | |
if (shape.radius) { | |
return Math.PI * Math.pow(shape.radius, 2) | |
} | |
else if (shape.height && shape.width) { | |
return shape.height * shape.width | |
} | |
else if (shape.base && shape.height) { | |
return 0.5 * shape.base * shape.height | |
} |