2017년 9월 25일 월요일

[wpf] border


     
   


이렇게 쓰면 된다. border안에 원하는 컨트롤 사용하면 그 컨트롤 밖에 경계가 쳐진다


2017년 9월 14일 목요일

[C#] Fast array to bitmap

public Bitmap CopyDataToBitmap( byte [ ] data , int w, int h)
{
//Here create the Bitmap to the know height, width and format
Bitmap bmp = new Bitmap( w, h, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);

//Create a BitmapData and Lock all pixels to be written
BitmapData bmpData = bmp.LockBits(
  new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
  ImageLockMode.WriteOnly, bmp.PixelFormat);

//Copy the data from the byte array into BitmapData.Scan0
Marshal.Copy( data , 0 , bmpData.Scan0 , data.Length );


//Unlock the pixels
bmp.UnlockBits( bmpData );


//Return the bitmap
return bmp;
}

2017년 9월 10일 일요일

funtor applicative monad different

*Main> [(\n -> [1..n])] <*> [1..5]
[[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5]]
*Main> [1..5] >>= \n -> [1..n]
[1,1,2,1,2,3,1,2,3,4,1,2,3,4,5]
*Main> [(\n -> [1..n])] <*> [1..5]
[[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5]]
*Main> fmap (\n -> [1..n]) [1..5]
[[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5]]
*Main> fmap [(\n -> [1..n])] [1..5]

:29:6: error:
    • Couldn't match expected type ‘Integer -> b’
                  with actual type ‘[Integer -> [Integer]]’
    • In the first argument of ‘fmap’, namely ‘[(\ n -> [1 .. n])]’
      In the expression: fmap [(\ n -> [1 .. n])] [1 .. 5]
      In an equation for ‘it’: it = fmap [(\ n -> [1 .. n])] [1 .. 5]
    • Relevant bindings include it :: [b] (bound at :29:1)
*Main>



1. Functor 는 [ 함수 ] 에서 함수를 꺼내 적용하는게 불가능
2. Applicative 는 [함수 ] 에서 함수를 꺼내 , 목표 리스트에 각각 적용후 다시 리스트 [ ] 로 감싼다.
3.Monad 는 함수 바인드를 하는데 결과는 같은 타입인 [ a ] 로 나오게 바뀐다.


book

Python Machine Learning by Sebastian Raschka (recommended)
-Building Machine Learning Systems with Python by by Luis Pedro Coelho and Willi Richert (nice to have for additional perspective)

2017년 9월 1일 금요일

[haskell] foldr foldl

foldr 이란?

foldr :: (a → b → b) → b → [a] → b
foldr [] = v
foldr f v (x:xs)
= f x ( foldr v xs )
f (x1 , ( f ( x2 , f ( x3 , [] )) )

EX>
foldr f v (x1:x1s)
= f x1 ( foldr v x1s )
= f x1 ( foldr v (x2:x2s) )
= f x1 ( f x2 ( foldr v x2s ))

foldl 이란?

foldl :: (a → a → a) → [a]→ a
foldl f v ( x : xs )
= foldl f f(v,x) xs
f ( f ( f ( v , x1) , x2 ) x3)

EX>
foldl f v ( x1 : x1s )
= foldl f f(v,x1) (x2,x2s) 
= foldl f f ( f(v,x1)  , x2  )  x2s

v 는 가장 처음에 f에 첫번재 파라미터로 들어가는 수