Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en" xmlns:mml="http://www.w3.org/1998/Math/MathML">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</head>
{-
VTree
This data structure was just written for the exercise,
especially in order to make it a (faithful) instance of the
typeclasses. It might be missing essential functionality
and is not optimized beyond Big O.
VTree is a self-balancing non-search binary tree with instances of
import sys
from copy import deepcopy
from itertools import chain
sys.setrecursionlimit(100000000)
string_lines = sys.stdin.read().split('\n')[:-1]
lines = [list(x) for x in map(lambda line: map(int, line.split(' ')), string_lines)]
n, k = lines.pop(0)
[m] = lines.pop(0)
n_aug = n + 1
namespace CheapIroning
open System
open System.Net
open FSharp.Data
open Newtonsoft.Json
open Newtonsoft.Json.Converters
let root = "https://cryptic-reef-6530.herokuapp.com/customer_api/"
// output: Async<'T>
let request<'T> str =
Http.AsyncRequestString <| sprintf "%s%s" root str
|> Async.map (fun raw -> JsonConvert.DeserializeObject<'T> raw)
type LoginResult =
| Success
| IncorrectPassword
(Server.login emailEntry.Text passwordEntry.Text) |> Async.map (fun res ->
match res with
| Server.Success -> f() // login
| Server.IncorrectPassword -> outputLabel.Text <- "Incorrect password"
| Server.EmailNotFound -> outputLabel.Text <- "Email not found"
| Server.NotActivated -> outputLabel.Text <- "Account not activated"
| _ -> outputLabel.Text <- "Error, please try again"
) |> Async.StartImmediate
namespace CheapIroning
open Xamarin.Forms
type App() as thisG =
// this works:
// inherit Application(NavigationPage(UnauthPage(fun () -> this.changeToLoggedIn |> ignore)))
// but afterwards, calling the passed function crashes the app
inherit Application()
let retrieveNumber = async {
printfn "retrieveNumber start"
do! Async.Sleep 4000
return 0
};;
let job1 = async {
do! Async.Sleep 500
printfn "Job done"
};;
let retrieveNumber = async {
do! Async.Sleep 4000
return 0
};;
let anotherJob = async {
do! Async.Sleep 500
};;
// start retrieving number;
# customer has_many addresses
# address has_many foo
# address has_many bar
# what I have
@customer = Customer.where(baz: 0)
@addresses = @customer.addresses.includes(:foo, :bar)
@addresses.each { |addr| p(addr.foo.int_column1 + addr.bar.int_column2) }
# what I want