A profile is defined for a user named lagénorhynque who is interested in programming languages, linguistics, law, politics, and mathematics. They are fluent in several languages including French and Russian. The document also discusses forming effective teams by focusing on communication, clear responsibilities, flexibility, addressing issues promptly, and continual learning and improvement.
This document defines a macro called my_macro in Clojure that takes a predicate and list of arguments and conditionally executes the arguments if the predicate returns true. It demonstrates calling my_macro with (= 1 2) which returns false and doesn't print "hello", but with (= 1 1) which returns true and prints "hello". It also shows compiling my_macro into a function that can be called directly later.
This document provides information about various languages including their linguistic classification, typology, word order, writing systems, and examples sentences. It compares the structures of English, French, German, Russian, Arabic, Chinese, and Turkish by noting their language family, typical word order, and how a similar sentence requesting a glass of white wine would be expressed in each.
20. リスト(類似コレクション)の構築・分解: Scala
scala> 1 :: 2 :: 3 :: Nil
val res0: List[Int] = List(1, 2, 3)
scala> Vector() :+ 1 :+ 2 :+ 3
val res1: Vector[Int] = Vector(1, 2, 3)
scala> List(1, 2, 3).head
val res2: Int = 1
scala> List(1, 2, 3).tail
val res3: List[Int] = List(2, 3)
// パターンマッチング
scala> val x :: xs = List(1, 2, 3): @unchecked
val x: Int = 1
val xs: List[Int] = List(2, 3)
scala> val ys :+ y = Vector(1, 2, 3): @unchecked
val ys: Vector[Int] = Vector(1, 2)
val y: Int = 3
scala> val (a, b, c) = (1, 2, 3)
val a: Int = 1
val b: Int = 2
val c: Int = 3
20
21. リスト(類似コレクション)の構築・分解: Haskell
> 1 : 2 : 3 : []
[1,2,3]
it :: Num a => [a]
> head [1, 2, 3]
1
it :: Num a => a
> tail [1, 2, 3]
[2,3]
it :: Num a => [a]
-- パターンマッチング
> x : xs = [1, 2, 3]
x :: Num a => a
xs :: Num a => [a]
> (x, xs) -- タプルでまとめて確認
(1,[2,3])
it :: (Num a1, Num a2) => (a1, [a2])
21
22. > (a, b, c) = (1, 2, 3)
a :: Num a => a
b :: Num b => b
c :: Num c => c
> [a, b, c] -- リストでまとめて確認
[1,2,3]
it :: Num a => [a]
22
27. 条件式if
;; Clojure
user=> (if (= 1 2) :t :f)
:f
# Elixir
iex(1)> if 1 == 2, do: :t, else: :f
:f
// Scala
scala> if (1 == 2) 't' else 'f'
val res0: Char = f
-- Haskell
> if 1 == 2 then 't' else 'f'
'f'
it :: Char
27
28. ラムダ式(a.k.a. 関数リテラル)
;; Clojure
(fn [x] (* x x))
#(* % %) ; 略記法
# Elixir
fn x -> x * x end
&(&1 * &1) # 略記法
// Scala
x => x * x
-- Haskell
x -> x * x
28
29. 定義式: Clojure, Elixir
;; Clojure
(def x 42)
(def f (fn [x] (* x x)))
(defn g [x] (* x x)) ; 上とほぼ等価な定義(メタデータに差が生じうる)
# Elixir
x = 42
f = fn x -> x * x end # 無名関数を束縛した変数
defmodule SomeModule do
def g(x), do: x * x # モジュールの名前付き関数
end
29
30. 定義式: Scala, Haskell
// Scala
val x = 42
val f = (x: Int) => x * x // 関数オブジェクトを束縛した変数
def g(x: Int) = x * x // メソッド(eta-expansionで上と等価に)
-- Haskell
x = 42
f = x -> x * x
g x = x * x -- 上と等価な定義
30