Skip to content

Instantly share code, notes, and snippets.

🐬
(*> ᴗ •*)ゞ

Kent OHASHI lagenorhynque

🐬
(*> ᴗ •*)ゞ
View GitHub Profile
View introduction-to-graphql.md

GraphQL入門


lagénorhynque

(defprofile lagénorhynque
  :id           @lagenorhynque
  :reading      "/laʒenɔʁɛ̃k/"
@lagenorhynque
lagenorhynque / higher_order_function_spec.clj
Last active Apr 18, 2020
Speccing a higher-order function with clojure.spec (+ test.check)
View higher_order_function_spec.clj
dev> (require '[clojure.spec.alpha :as s]
'[clojure.spec.test.alpha :as stest])
nil
dev> (defn twice [f x]
(f (f x)))
#'dev/twice
dev> (s/fdef twice
:args (s/cat :f (s/fspec :args (s/tuple integer?)
:ret integer?)
:x integer?)
@lagenorhynque
lagenorhynque / fizzbuzz_list.hs
Last active Apr 13, 2020
FizzBuzz as infinite sequence in Clojure/Haskell
View fizzbuzz_list.hs
> fizzBuzz = map (\(f, b, n) -> maybe "" id f ++ maybe "" id b ++ (if null f && null b then show n else "")) $ zip3 (cycle [Nothing, Nothing, Just "Fizz"]) (cycle [Nothing, Nothing, Nothing, Nothing, Just "Buzz"]) [1..]
fizzBuzz :: [[Char]]
[Prelude]
> take 30 fizzBuzz
["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz","16","17","Fizz","19","Buzz","Fizz","22","23","Fizz","Buzz","26","Fizz","28","29","FizzBuzz"]
it :: [[Char]]
[Prelude]
> import Data.Maybe
[Prelude Data.Maybe]
> fizzBuzz' = map (\(f, b, n) -> fromMaybe "" f ++ fromMaybe "" b ++ (if null f && null b then show n else "")) $ zip3 (cycle [Nothing, Nothing, Just "Fizz"]) (cycle [Nothing, Nothing, Nothing, Nothing, Just "Buzz"]) [1..]
View fun-of-multi-language-learning.md

たのしい多言語学習

実例とともに言語学の基礎知識を学ぼう


lagénorhynque

(defprofile lagénorhynque
@lagenorhynque
lagenorhynque / case_class.scala
Created Mar 19, 2020
Clojure's records, Scala's case classes & Java's records
View case_class.scala
$ scala
Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 14).
Type in expressions for evaluation. Or try :help.
scala> case class Point(x: Int, y: Int) {
| def +(other: Point): Point = Point(this.x + other.x, this.y + other.y)
| }
defined class Point
scala> val p1 = Point(1, 2)
@lagenorhynque
lagenorhynque / repl.clj
Last active Mar 14, 2020
libpython-clj usage examples (Clojure ❤️ Python?)
View repl.clj
dev> (require '[libpython-clj.python :as py])
nil
dev> (py/initialize! :python-executable venv-python
:library-path dylib-path)
...
dev> (require '[libpython-clj.require :refer [require-python]])
nil
dev> (require-python '[numpy :as np]
'[numpy.random :as np.rand]
'[pandas :as pd])
@lagenorhynque
lagenorhynque / if_let_macro.clj
Created Jan 9, 2020
Walrus operator in Python 3.8 vs if-let macro in Clojure
View if_let_macro.clj
dev> (if-let [coll (seq [1 2 3])]
(println coll)
(println "EMPTY"))
(1 2 3)
nil
dev> (if-let [coll (seq [])]
(println coll)
(println "EMPTY"))
EMPTY
nil
View duct-module-getting-started.md

Ductモジュール入門

Clojureフレームワーク"Duct"の拡張方法を理解しよう

lagénorhynque

(defprofile lagénorhynque
View clojure-repl-the-good-parts.md

Clojure REPL: The Good Parts


lagénorhynque

(defprofile lagénorhynque
  :id           @lagenorhynque
  :reading      "/laʒenɔʁɛ̃k/"
You can’t perform that action at this time.