pattern-matching

    4

    2答えて

    文字列からオブジェクトを抽出する抽出機能を持っています。 case class ItemStructure(id: String, data: String) object ItemStructure { def unapply(str: String): Option[ItemStructure] = { str.split('-').toList match {

    0

    3答えて

    特定の接頭辞と数字のパターンが増えたデータセット(たとえば* .dta)をグローバル環境に読み込んでリストにまとめたいと考えています。 (この特殊なケースでは、彼らは同じ次元のすべてだ。) 伝統的にIコード: library(foreign) # for reading *.dta files df_1 <- read.dta("df_1.dta") df_2 <- read.dta("df

    1

    1答えて

    動物が人物で、その名前がAlexの場合に検証します。 Personオブジェクト: type Person(name: string) = member this.Name = name Enumration: type Animal = | Person of Person | Cat | Dog パターン・マッチング:あなたはwhenでパターンガードを指定することができ

    0

    1答えて

    私の新しいことをOCamlに許してください。しかし、私は2つのリストの交差を返す非常に単純な関数を持っていますが、同時に両方のリストに要素があるときだけです。 3行目では、「この式には 'a'型がありますが、式には 'a list'が期待されていますが、出力するリストではありません。 let rec intersection (l1 : 'a list) (l2 : 'a list) : 'a l

    1

    1答えて

    私の下のコードは、母音の最初の一致を見つけるために働きます。この場合は'ua'ですが、最初の検索で終わる前に文字列全体を検索するにはどうすればよいですか? 2)ステップ1が完了したら、どのパターンのどれが母音の最長並行性を示すかを決定する。その後、 import re s = "quality" matches = re.search(r"[aeiou]+", s) matchlist =

    1

    1答えて

    私は、次のような更新機能を持っています。 どうやら、_だからで update : Msg -> Model -> (Model, Cmd Msg) update msg model = case msg of NewImages (Ok images) -> ({model|images = images}, Cmd.none) NewUsers

    0

    2答えて

    は、私は別のソリューションの多くの亜種は、括弧(と、より多くの)について、ここで How to add space on both sides of a string in Java Regex add space between all punctuation Add space after capital letter だけでなく、他のものを説明しようとした Regex to match pa

    0

    2答えて

    I(これは方法より簡単である可能性があるという事実を無視してください) type tKey = Key of int;; type tBST = Null | Pos of node ref and node = {mutable key : tKey; mutable left : tBST; mutable right : tBST};; 私は私

    -2

    1答えて

    私は3行目のエラーを取得しています、私のリスト上の私の最初の二つの要素を追加する をしようとしています、なぜですか? let addfirsttwo lst = match lst with | List.hd lst + List.hd (List.tl lst) ;;

    3

    2答えて

    でケースを簡素化し、私は次のコードスニペットを持っている、のは、言ってみましょう: val num = Future.successful(10) num map { case n if n > 0 => // do something case _ // do something } 私の質問は:私は何とかcase n if n > 0を簡略化することができま