Elixir Language
ヒントとテクニック
サーチ…
前書き
エリクシールコーディング中に時間を節約する高度なヒントとテクニック。
カスタムサインとドキュメントの作成
各x sigilはそれぞれのsigil_x定義を呼び出します
カスタムサインの定義
defmodule MySigils do #returns the downcasing string if option l is given then returns the list of downcase letters def sigil_l(string,[]), do: String.Casing.downcase(string) def sigil_l(string,[?l]), do: String.Casing.downcase(string) |> String.graphemes #returns the upcasing string if option l is given then returns the list of downcase letters def sigil_u(string,[]), do: String.Casing.upcase(string) def sigil_u(string,[?l]), do: String.Casing.upcase(string) |> String.graphemes end
複数の[OR]
これは、複数のOR条件を書くもう1つの方法です。これは推奨アプローチではありません。通常の手法では、条件が真であると評価されるため、リスト内のすべての条件を最初に評価するこのアプローチとは異なり、評価時間を節約する残りの条件の実行を停止します。これはちょうど悪いですが、発見には良いことです。
# Regular Approach find = fn(x) when x>10 or x<5 or x==7 -> x end # Our Hack hell = fn(x) when true in [x>10,x<5,x==7] -> x end
iexカスタム設定 - iexデコレーション
コンテンツをファイルにコピーし、ファイルを.iex.exsとして〜のホームディレクトリに保存し、その魔法を見てください。 ここでファイルをダウンロードすることもできます
# IEx.configure colors: [enabled: true]
# IEx.configure colors: [ eval_result: [ :cyan, :bright ] ]
IO.puts IO.ANSI.red_background() <> IO.ANSI.white() <> " ❄❄❄ Good Luck with Elixir ❄❄❄ " <> IO.ANSI.reset
Application.put_env(:elixir, :ansi_enabled, true)
IEx.configure(
colors: [
eval_result: [:green, :bright] ,
eval_error: [[:red,:bright,"Bug Bug ..!!"]],
eval_info: [:yellow, :bright ],
],
default_prompt: [
"\e[G", # ANSI CHA, move cursor to column 1
:white,
"I",
:red,
"❤" , # plain string
:green,
"%prefix",:white,"|",
:blue,
"%counter",
:white,
"|",
:red,
"▶" , # plain string
:white,
"▶▶" , # plain string
# ❤ ❤-»" , # plain string
:reset
] |> IO.ANSI.format |> IO.chardata_to_string
)
Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow