Single-case Active Pattern is defined as a special function enclosed (| |).
> open System;; > let (|WhatDayOfWeek|) (year, month, day) = - System.DateTime(year,month,day).DayOfWeek;; val ( |WhatDayOfWeek| ) : year:int * month:int * day:int -> DayOfWeek > let isWeekEnd year month day = - match (year, month, day) with - | WhatDayOfWeek System.DayOfWeek.Sunday - | WhatDayOfWeek System.DayOfWeek.Saturday - -> true - | WhatDayOfWeek _ - -> false;; val isWeekEnd : year:int -> month:int -> day:int -> bool > isWeekEnd 2013 3 15;; val it : bool = false > isWeekEnd 2013 3 16;; val it : bool = true
No comments:
Post a Comment