小编min*_*l.m的帖子

正则表达式 f#

如何使用函数式方法做正则表达式?目前我希望用户输入一个输入,即使他们以大写字母输入它仍然会给出响应吗?我不确定如何实现这一点。

open System
open System.Drawing 
open System.Windows.Forms

let (|Hello|Bye|None|) input =
match input with
    | "hello" | "hi" | "morning" 
            -> Hello
    | "Goodbye" | "bye" | "go"
            -> Bye
    | _     
            -> None

   let rand = new Random()

   let hello_response () =
   let n = rand.Next(10) 
   match n with
    | 0 -> "How do you do."
    | 1 -> "Is nice talking to you."
    | 2 -> "Tell me something new."
    | 3 -> "Nice to meet you."
    | …
Run Code Online (Sandbox Code Playgroud)

regex f# functional-programming

6
推荐指数
1
解决办法
4035
查看次数

标签 统计

f# ×1

functional-programming ×1

regex ×1