Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //task2 lab1
- (*
- let list = [
- for i in 1 .. 10 do
- yield (1+i)*i/2-i+1
- ]
- printf "%A" list
- *)
- //task1 lab2
- (*
- let list123 = [ 1; 2; 3;4 ]
- let rec printList listx max =
- match listx with
- | head :: tail -> if head%2=0&&max<head then printList tail head
- else printList tail max
- | [] -> max
- let ans = printList list123 -1
- printf "%A" ans
- *)
- //task2 lab2
- (*
- let list = List.rev [0; 1;2;1; 0 ]
- //printf "%A" list
- let checkPalindrom list listRev = List.fold2 (fun acc elem1 elem2 -> if (elem1 <> elem2) then false else acc ) true list listRev
- let ans = checkPalindrom list (List.rev list)
- printf "%A" ans
- *)
- //task3 lab2
- (*
- let s = seq { 2; 5; 4; 7; 11; 16}
- // let s = seq { 2; 5; 8; 11; 14; 17}
- let seqWindows = Seq.windowed 2 s
- let seqSubtract = Seq.map (fun elem->(Array.get elem 1) - (Array.get elem 0)) seqWindows
- let d = Seq.head seqSubtract
- let f = Seq.fold (fun acc elem -> if (Seq.head seqSubtract <> elem) then false else acc ) true seqSubtract
- let a1 = Seq.head s
- if f then printf "Это арифмитическая прогрессия . а1= %A ,d = %A " a1 d
- else printf "Не арифмитическая прогрессия ."
- *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement