Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- open System.IO
- //1
- type formatText=
- | Simplestr of string
- | Bullet_item of List<formatText>
- | Bold_text of formatText
- | Italic_text of formatText
- | Headers of formatText
- //2
- let rec render formatText =
- match formatText with
- | Simplestr(x) -> printf "%s" x
- | Bullet_item(x) -> List.iter(fun elem -> printf "</> %s" "";render(elem);printf "\n") x
- | Bold_text(x) -> printf "<B> %s" ""; render(x)
- | Italic_text(x) -> printf "<I> %s" ""; render(x)
- | Headers(x) -> printf "<H> %s" ""; render(x)
- let example = Bullet_item([Bold_text(Simplestr("1TEST"));Simplestr("2TEST");Italic_text(Simplestr("3TEST"));Bullet_item([Simplestr("111TEST");Simplestr("222TEST");Simplestr("333TEST")])])
- render(example)
- render(Headers(Italic_text(Bold_text(Simplestr("nsd")))))
- //3
- ///////////////////////////////////////
- let rec min = function
- | [] -> failwith("error")
- | [x] -> (x,[])
- | h::t ->
- let (x1,y1) = min t
- if h<x1 then (h,t)
- else (x1,h::y1)
- min [2;3;1;3]
- let rec sort = function
- | [] -> []
- | S ->
- let (x1,y1)= min S
- (x1::(sort y1))
- sort [2;3;1;3]
- let rec F =function
- | [] -> []
- | h::t ->h:: F(List.filter (fun x->x%h<>0) t)
- F [2..100]
- let Flength =
- let rec len a = function
- | [] -> a
- | _::t -> len (a+1) t in len 0
- [1;2;34;32;1;23;1;0;2]
- |> List.sort
- List.groupBy(fun x->x%3) [1;2;3;4;5;6;7;8;9]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement