Comment detail

税込み価格への修正 (Nested Flatten)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
open System;;
open System.Text.RegularExpressions;;

let yen:string = "円";;

let tax str =
    let re = new Regex( "\d+" ^ yen ) in
    let matches = Seq.to_list { for m in re.Matches( str ) -> m.ToString() } in
    let getPrice (s:string) = Int32.Parse(s.Replace(yen, "")) in
    let taxes s = ((getPrice s) * 105 / 100).ToString() ^ yen in
    let rec replace (base:string) = function
        | [] -> base
        | m::ms -> replace (base.Replace(m,(taxes m))) ms in
    replace str matches;;

Index

Feed

Other

Link

Pathtraq

loading...