Map [1]
Operation | Time Complexity |
---|---|
Access | O(log n) |
Search | O(log n) |
Insertion | O(n) for <= 32 elements, O(log n) for > 32 elements [2] |
Deletion | O(n) for <= 32 elements, O(log n) for > 32 elements |
defmodule NestedWeb.FormLive do | |
use NestedWeb, :live_view | |
require Logger | |
defmodule Form do | |
use Ecto.Schema | |
import Ecto.Changeset | |
embedded_schema do | |
field :name, :string |
convert("one hundred five"); // "105" | |
convert("six hundred and fifty three"); // "653" | |
convert("zero zero one two three"); // "123" | |
convert("twelve o three"); // "1203" | |
convert("thirteen zero nine"); // "1309" | |
convert("fifteen sixteen"); // "1516" | |
convert("fourteen ninety two"); // "1492" | |
convert("nineteen ten"); // "1910" | |
convert("twelve hundred"); // "1200" | |
convert("twenty three hundred"); // "2300" |
TRUE = lambda x: lambda y: x | |
FALSE = lambda x: lambda y: y | |
Product = lambda x: lambda y: lambda z: (z)(x)(y) | |
And = lambda x: lambda y: (x)(y)(x) | |
Not = lambda x: lambda y: lambda z: (x)(z)(y) | |
Boolean = (Product)(True)(False) | |
Succ = lambda x: lambda y: lambda z: (y)((x)(y)(z)) | |
Pred = lambda x: lambda y: lambda z: x(lambda i: lambda j: j(i(y))) (lambda k: z) (lambda k: k) | |
Y = lambda g: (lambda z:z(z)) (lambda f: g(lambda arg: f(f)(arg))) | |
Nth = Y(lambda f: lambda n: Succ(f(n-1)) if n else Zero) |
# Haskell stack project Github Actions template | |
# https://gist.github.com/mstksg/11f753d891cee5980326a8ea8c865233 | |
# | |
# To use, mainly change the list in 'plans' and modify 'include' for | |
# any OS package manager deps. | |
# | |
# Currently not working for cabal-install >= 3 | |
# | |
# Based on https://raw.githubusercontent.com/commercialhaskell/stack/stable/doc/travis-complex.yml | |
# |
defmodule SqlParser do | |
def run() do | |
input = "select col1 from ( | |
select col2, col3 from ( | |
select col4, col5, col6 from some_table | |
) | |
) | |
" | |
IO.puts("input: #{inspect(input)}\n") | |
IO.inspect(parse(input)) |
(This is a translation of the original article in Japanese by moratorium08.)
(UPDATE (22/3/2019): Added some corrections provided by the original author.)
Writing your own OS to run on a handmade CPU is a pretty ambitious project, but I've managed to get it working pretty well so I'm going to write some notes about how I did it.
#!/usr/bin/env bash | |
# | |
# Script that detects if Scala's SBT is installed and if | |
# not then it automatically downloads and installs it at | |
# a specified path. | |
# | |
# Author: Alexandru Nedelcu (https://alexn.org) | |
# | |
set -e |
package fpmax | |
import scala.util.Try | |
import scala.io.StdIn.readLine | |
object App0 { | |
def main: Unit = { | |
println("What is your name?") | |
val name = readLine() |