我們將安裝下列項目:
- Elixir
- Node.js
- Postgresql 資料庫
- Phoenix
由於 macOS 及 linux 可以使用 asdf 這個語言版本管理器,所以我們將介紹用它來安裝 elixir 及 nodejs 的方式。而 Windows 則會使用 chocolatey 來安裝。
goldbach :: Int -> Maybe(Int, Int) | |
goldbach n = search halfOfPrimes where | |
search [] = Nothing | |
search (x:xs) = if isPrime (n - x) then Just (x, n - x) else search xs | |
halfOfPrimes = 2 : [ x | x <- [3, 5..half], isPrime x] | |
half = div n 2 | |
isPrime :: Int -> Bool | |
isPrime 2 = True | |
isPrime n = not $ any isFactor (2 : [3, 5 .. (square n)]) |
<li class='fruits'>Apple</li> | |
<li class='fruits'>Banana</li> | |
<li class='fruits'>Coconut</li> | |
<li class='fruits'>Cherry</li> | |
<li class='fruits'>Pear</li> |
<!DOCTYPE> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Dom sample page</title> | |
<link rel="stylesheet" href="../css/main.css"/> | |
<style> | |
.found-element | |
{ | |
border: 2px solid #000000; |
module Histogram where | |
import Data.List (unfoldr, foldl') | |
histogram :: [Int] -> String | |
histogram = addFootter . unlines . graph . tally where | |
addFootter s = s ++ "==========\n0123456789\n" | |
tally :: [Int] -> [(Int, Int)] | |
tally = foldl' accu ary where | |
ary = zip [0..9] (repeat 0) |
nub' :: [Int] -> [Int] | |
nub' = foldr f [] where | |
f x xs | |
| x `elem` xs = xs | |
| otherwise = x:xs | |
-- without using `elem` | |
nub'' :: [Int] -> [Int] | |
nub'' = foldr f [] where | |
f x xs |
defmodule Food do | |
def reduce([], _), do: "😵" | |
def reduce(foods, f), do: Enum.reduce(foods, f) | |
def eat(_, "💀"), do: "💀" | |
def eat(stuff, _) do | |
if is_food(stuff), do: "💩", else: "💀" | |
end | |
def is_food(_), do: true # implement yourself |
我們將安裝下列項目:
由於 macOS 及 linux 可以使用 asdf 這個語言版本管理器,所以我們將介紹用它來安裝 elixir 及 nodejs 的方式。而 Windows 則會使用 chocolatey 來安裝。
{ | |
"description": "Left Command to Switch Input Source", | |
"manipulators": [ | |
{ | |
"conditions": [ | |
{ | |
"type": "input_source_if", | |
"input_sources": [ | |
{ | |
"language": "en" |
defmodule RescueDemo do | |
def main do | |
data | |
|> wrapper_action | |
|> follow_up_function | |
end | |
def wrapper_action(data) do | |
try do | |
dangerous_action(data) |