Advertisement
Guest User

Untitled

a guest
May 12th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.03 KB | None | 0 0
  1. let listaPrzystychIPodzielnychPrzez3 (lista:int list) =
  2.     let rec dodajDoListy lista element =
  3.         match lista with
  4.         | [] -> [element]
  5.         | head :: tail -> (head::element::tail)
  6.    
  7.     let rec parzyste (lista:int list) (lParzyste:int list) =
  8.         match lista with
  9.         | [] -> lParzyste
  10.         | head :: tail -> if head % 2 = 0
  11.                           then
  12.                             parzyste tail (dodajDoListy lParzyste head)
  13.                           else
  14.                             parzyste tail lParzyste
  15.  
  16.     let rec podzielne lista lPodzielne =
  17.         match lista with
  18.             | [] -> lPodzielne
  19.             | head :: tail -> if head % 3 = 0
  20.                               then
  21.                                 podzielne tail (dodajDoListy lPodzielne head)
  22.                               else
  23.                                 podzielne tail lPodzielne
  24.  
  25.     (parzyste lista ([]:int list), podzielne lista ([]:int list))
  26.  
  27. listaPrzystychIPodzielnychPrzez3 [1; 2; 3; 4; 5; 6; 7; 8; 9; 12]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement