Amazon EchoのSkill Kitが面白い。 Amazon Lambdaを使って簡単なSkill Kitを使ったアプリケーションを作ることが可能なのだが、本当に対話的なやり取りを実現できる。 https://github.com/amzn/alexa-skills-kit-js/tree/master/samples/helloWorld このサンプルを使うと、 私 > Alexa, ask greeter Alexa > Welcome to the Alexa Skills Kit, you can say hello 私 > Hello Alexa > Hello World と言う感じで応答ができる。この時、私がHelloというまで You can say hello と言いながらある程度待ってくれる。 体験が変わる。 さぁ、こういう体験が出てきた時、 Quality はどうなるだろう。 ちなみに、まだ日本語は発してくれない。 https://github.com/KazuCocoa/alexa-helloworldMore
Category Archives: development
[Elixir]Keywordの中身はTupleのList
Elixirに置いて、Keyword listはTupleで表現される。 なので、 のようなパイプを書いた時、取得されるのは [“hello”] になる。 ここで、Elixir v1.2.3 の Keyword.valuesの中身を覗いてみると、以下のようにmapを適用した中でTupleからちょうどvalueを取得してListを作って返している。 当初、 しか Keyword 系は使えないと思っていたけれど、Erlangレベルでは なので、Keyword listとみなしてKeyword操作ができるのですね。学びだ。 蛇足だけれど、 Enum.any?/2 と言う、処理の途中で要素が見つかったらtrueを返す用途で使うfunctionも教えてもらった。なるほど。More
[Erlang][Elixir]Efficiency Guide User’s GuideでErlang/Elixirを知る
ErlangのEfficiency Guideが役立ったので、メモ。 Erlang/Elixirをやるなら知っておくべきことが多数ありました。 私が読んだのは、version 7.3 http://erlang.org/doc/efficiency_guide/introduction.html また、 http://erlang.org/doc/efficiency_guide/advanced.html にはAtomと言った型に対する制限であったり、メモリの制限などのまとまった情報を得ることができます。他、List操作に対する注意ごとや、tail recuesiveにすることの良さなど。More
[Swift]Regular Expression with Swift
Swiftのexercism.iosを解いている時に、正規表現を使いたい箇所に出くわしました。 Swift、ObjCのそれを使わないといけないのですね。私が扱う言語の中では一番手間隙がかかるやつでした。 メモメモ。以下は、入力文字列に対して 0-9 の数字を文字列として抜き出すメソッドです。 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 Show hidden characters private func format(startingNumber: String) -> String { let pattern…More
[Elixir]refactor to use pattern match in function instead of case one
exercism.ioで実装した問題を、 case 使って書いてたのですが、冗長なのでメソッドのパターンマッチを使って簡略化しました。 思いの外削減できたので、メモ。 特に、 can_attack? のところのパターンマッチは他の言語で書いた後に戻って書こうとするとパッと思い浮かばないときもある。。。 case でちんたら… が初めのやつ。pattern mach in functionが修正版。 case でちんたら… defmodule Queens do @type t :: %Queens{ black: {integer, integer}, white: {integer, integer} } defstruct black: {7, 3}, white: {0, 3} @doc “”” Creates a new set of Queens “”” @spec new(nil | list) :: Queens.t() def new(positions \\ nil)…More
[Elixir][Erlang]listと、filterの使い心地
ErlangもElixirも、 filter を使う操作で簡単に特定の条件に合致した要素だけのリストを作ることができます。ただ、 filter を使わないで簡単に同様な処理を表現する方法が、Erlangだけでしか思いつかなかったです。。 ただ、ここでElixirにおける for を良い感じで使いたい問題があったのでそちらも。 generate List with for syntax と書いている箇所です。 2つ以上のリストの組み合わせを入力とした処理を書きたい時、書きやすい形で処理を表現できますね。 How to generate list with filter or other ways. Erlang > [X || X <- lists:seq(1, 5), X rem 3 == 0]. [3] > lists:filter(fun(X) -> X rem 3 == 0 end, lists:seq(1, 5)). [3] Elixir > (for x <-…More
[Erlang][Elixir]binaryの扱い
Erlangにおけるbinaryのコピー、参照の扱いに関してメモ。 64 byteまではheap binariesと言われて、メッセージを渡す時にコピーを渡してprocessのheapに保存するらしいです。 一方、それ以上は参照渡しになるらしいです。 なるほど。 参考 http://erlang.org/doc/efficiency_guide/binaryhandling.html http://stackoverflow.com/questions/3406425/does-erlang-always-copy-messages-between-processes-on-the-same-node Vさんの以下が参考になりました。 Erlang のバイナリ特別扱いについては https://t.co/JCfyVIZQhx を見れば書いてあります。日本語は @shibu_jp が翻訳したこちら。https://t.co/c9ssNKHchV — V (@voluntas) March 20, 2016 ネットワークサーバ書く場合は、 binary はコピーされないっての結構大事な話なので覚えておくと良いですよ。設計に影響する。 — V (@voluntas) March 20, 2016 なので、 atom と binary は凄く積極的に使いましょう。ただし atom を動的生成はしてはだめですよ。 — V (@voluntas) March 20, 2016 こっちも読んでいこう。 http://erlang.org/doc/efficiency_guide/introduction.htmlMore
[Elixir]正規表現のグループ化、後方一致メモ
Erlang/Elixirは、Perlの正規表現に沿っています。なので、メタ文字などの細かな箇所はそれにそう形になります。 参考: http://erlang.org/doc/man/re.html その中で、後方一致の時の挙動なんかがパッとわかってなかったので、メモ。 グループ化した ([A-Z]) に対して、同じ文字を0回以上繰り返すものを同一のグループとしてみなします。その結果はリストの [“全ての文字列”, “繰り返される値”] という形になります。 日本語でも、こちらを参考に理解を進めたので、メモ。 http://doc.mas3.net/regexp/#backreferenceMore
[Elixir][Erlang]run functions like yield
These days, I challenge exercism.io to get used some languages. Especially, I use Erlang and Swift. Then, I found some difference between Erlang and Elixir in aspect of syntax. So, I describe them as articles to remember them. This time, I attached gist which is run function defined in variables. Elixir run them with func.(),…More
[Elixir][Erlang]difference of binary
double quote and single quote have different meanings between Elixir and Erlang. In addition, “$” and “?” also have. They make me confuse a bit … 😦 Elixir > ?a 97 > [?a] == ‘a’ true > [?a] == “a” false > is_bitstring “a” true > is_bitstring ‘a’ false Erlang > $a. 97 > [$a]…More