This file contains hidden or 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
| {_, server} = "https://api.github.com" | |
| |> HTTPoison.get! | |
| |> Map.get(:headers) | |
| |> Enum.filter(&match?({"Server", _}, &1)) | |
| |> List.first | |
| {_, server} = "https://api.github.com" | |
| |> HTTPoison.get! | |
| |> Map.get(:headers) | |
| |> List.keyfind("Server", 0) |
This file contains hidden or 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
| (defn fact | |
| [x] | |
| (cond | |
| (zero? x) 1 | |
| (= x 1) 1 | |
| :else (* x (fact (dec x))))) |
This file contains hidden or 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
| (def mm '[{:a 1, :b 2} {:a 2, :b 3}]) | |
| (map #(dissoc % :a) mm) |
This file contains hidden or 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
| (def header-lines ["Host: example.com" "User-Agent: ExampleBrowser/1.0" "Accept: */*" | |
| "Content-Type: application/x-www-form-urlencoded" "Content-Length: 21"]) | |
| (:require '[clojure.string :as str]) | |
| (->> (map #(let [[k v] (str/split % #": ")] | |
| [(keyword k) v]) header-lines) | |
| (into {})) | |
| ;;str/split function |
This file contains hidden or 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
| module GetDrivers = [%graphql | |
| {| | |
| query getDrivers{ | |
| all_drivers { | |
| id | |
| name | |
| } | |
| } | |
| |} |
This file contains hidden or 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
| type SortDirection = Asc | Desc | |
| type alias SortedLabels = {labels: List String , direction: SortDirection } | |
| type alias Article = { name: String, keywords: SortedLabels } | |
| addArticles: String -> List Article -> List Article | |
| addArticles name article = | |
| Article name (SortedLabels [] Asc) :: article | |
| --Call the function | |
| addArticles "food" [Article "start" (SortedLabels ["foo", "bar"] Asc), Article "start" (SortedLabels ["foo", "bar"] Asc)] |
This file contains hidden or 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
| module Main where | |
| import Prelude (show, ($), (=<<), (+), (<>), (*), (-)) | |
| import Control.Monad.Eff.Console(log) | |
| import TryPureScript | |
| fact :: Int -> Int | |
| fact 0 = 1 | |
| fact n = n * fact(n-1) |
This file contains hidden or 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 Html exposing (text) | |
| fact : Int -> Int | |
| fact n = | |
| case n of | |
| 0 -> 1 | |
| 1 -> 1 | |
| _ -> n * fact(n-1) | |
| factorial : Int -> Int |
This file contains hidden or 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
| module Main exposing (..) | |
| import Html exposing (Html, div, fieldset, input, label, text) | |
| import Html.Attributes exposing (name, style, type_) | |
| import Html.Events exposing (onClick) | |
| -- MODEL | |
This file contains hidden or 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
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println(`Enter the number of integers`) | |
| var n int | |
| if m, err := fmt.Scan(&n); m != 1 { | |
| panic(err) | |
| } |
NewerOlder