Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System.Collections.Generic
- let tab2d = array2D [[0;0;0;1];[0;0;0;0];[0;0;0;1];[0;1;0;0]]
- //.WYPISZ
- for i = 0 to 3 do
- for j = 0 to 3 do
- printf "%A " tab2d.[i,j]
- printf "\n"
- printf "\n"
- //.WYPISZ SOMSIADUF
- for i = 0 to 3 do
- printf "%A" i
- printf ".["
- for j = 0 to 3 do
- if tab2d.[i,j] =1 then printf "%A " j; printf ","
- printf "]\n"
- printf "\n"
- //somsiedzi wieszcholka
- let smosiedzi_wierzcholka node ()=
- printf "%A" node
- printf ".["
- for j = 0 to 3 do
- if tab2d.[node,j] =1 then printf "%A " j; printf ","
- printf "]\n"
- printf "\n"
- smosiedzi_wierzcholka 2 ()
- //TRANSPOZE
- let transpozed tab = Array2D.init (Array2D.length2 tab) (Array2D.length1 tab) (fun r c -> tab.[c,r])
- let tab_t = transpozed tab2d
- type Lista<'a> =
- | Data of 'a * Lista<'a> ref
- | Nil
- //333333 zadoo
- let rnd = new System.Random()
- let losy = new Dictionary<int,int>();;
- for i=0 to 100 do
- let los = rnd.Next(0,10)
- let (ya, buff) = losy.TryGetValue(los)
- if ya then
- losy.Remove(los)
- losy.Add(los, (buff+1))
- else
- losy.Add(los, 1)
- for i=0 to 9 do
- printf "%A " i
- printf ".= "
- let (ya, buff) = losy.TryGetValue(i)
- if ya then
- printf "%A " buff
- printf "\n"
- //TRANSPOZE
- let primed tab = Array.init (Array2D.length1 tab) (fun i ->[ for j in [0..3] do if tab.[i,j]=1 then yield j ] )
- let primed2MAP tab = List.init (Array2D.length1 tab) (fun i ->[ for j in [0..3] do if tab.[i,j]=1 then yield j ] )|>List.indexed |> Map.ofList
- printf "\n"
- printfn "%A" (primed tab2d)
- printf "\n"
- printfn "%A" (primed2MAP tab2d)
- //part twoooooooooooooooooooooooo
- type Lista<'a> =
- | Data of 'a * Lista<'a> ref
- | Nil
- //let rec zlicz l ilosc =
- // match l with
- // |> Data (a, ref)-> zlicz l.Data.value (ilosc+1)
- // |> Nil -> ilosc
- //wypisz
- //let rec wypisz l=
- // match l with
- // |> Data -> printf "%A" Data.value; zlicz l.Data.value
- // |> Nil -> printf "end"
- //dodaj
- //let rec zlicz l=
- // match l with
- // |> Data -> printf "%A" Data.value; zlicz l.Data.value
- // |> Nil -> l.Data.value = new 'a * Lista<'a>
Add Comment
Please, Sign In to add comment