This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(){ | |
int value[] = {2,5,4,3,8,7,9,1,10,6}; | |
int index[] = {0,1,2,3,4,5,6,7,8,9}; | |
int cmp(const void * a, const void * b){ | |
return value[*(int*)a] - value[*(int*)b]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*XXXXXXXXXNXNNXXXXXNNNNNNNNNXKxoloodddddx0XXk0XXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNN | |
XXXXXXXXXXXXXXXXXXXNNNNNNXKkdlccllccllccloodOdddxk0KKXXXNNNNNNNNNNNNNNNNNNNNNNNN | |
XXXXXXXXXXXXXXXXXXXXXXKxc,.''',,;;;,,'....,,'''.,',cdxO0KXNNNNNNNNNNNNNNNNNNNNNN | |
XXXXXXXXXXXXXXXXXXXXx:........''''..''...........''',:coxOKXNNNNNNNNNNNNNNNNNNNN | |
XXXXXXXXXXXXXXXXX0l...................................'',;:lkXXNNNNNNNNNNNNNNNNN | |
XXXXXXXXXXXXXXX0,................''.....................'',,,;o0XNNNNNNNNNNNNNNN | |
XXXXXXXXXXXXXXK;.........................................'.'''''lKNNNNNNNNNNNNNN | |
XXXXXXXXXXXXX0c..................'................. .. ...'......,kXNNNNNNNNNNNN | |
XXXXXXXXXXXK:. .............'...........''......'..... ....'......'dXNNNNNNNNNNN | |
XXXXXXXXXXO. .... ...........................'''.......''.',.......xNNNNNNNNNNN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval(join('',qw{$_=q{eval(join('',qw{$_=q{};$s=sub{substr($o,0,1,'')};($p,$P,$_)=/(.{21})(.{428})(.*)/;$l=0+$_;($_,$d)=/(.{$l})(.*)/;$o="$p$P$d$_";($w,$h,$_)=/\d+\D(\d+)\D(\d+)\D(.*)/;@_=split/\D/;$b=$_[-1]||pop@_;$u=scalar($o)x($w*$h);$u=~y/{}#//d;$o="$p$o${P}q#$u";$o=~s/(.*)\x7D/$1.chr(92).'x7D'/e;$f=substr($o,0,$w+2,'').$/;for(1..$h){$f.=&$s;for(1..$w){$f.=$b?&$s:chr(32);--$_[-1]||pop@_||($b=!$b);}$f.=&$s.$/;}$f.=&$s()for(3..$w);$f.="#}))\n";caller(1)?$f:print$f;930,149,46,1074,6,9,6,12,2,2,2,19,3,1,3,3,1,12,5,1,2,60,6,8,8,8,5,2,5,13,6,1,8,8,8,1,4,58,7,8,6,8,5,4,5,10,6,4,7,7,8,3,4,57,7,9,4,8,5,6,5,8,6,7,5,6,8,4,5,56,8,9,2,8,6,6,6,7,5,9,4,6,8,3,7,55,8,9,2,7,7,6,7,5,6,9,4,5,9,3,7,55,9,8,2,7,7,6,7,5,6,10,3,5,9,2,8,55,10,7,2,6,8,6,8,3,8,9,3,5,9,2,8,55,10,7,2,6,8,6,8,3,10,7,3,5,9,2,7,56,11,6,2,6,8,6,8,3,12,6,2,5,9,3,6,57,10,6,2,6,8,6,8,3,15,10,9,4,4,58,11,5,2,5,9,6,9,2,16,9,9,65,1,1,10,5,2,5,9,6,9,3,17,7,9,65,1,2,10,4,2,5,9,6,9,3,18,6,9,65,1,2,11,3,2,5,9,6,9,4,18,5,9,65,2,2,10,3,2,5,9,6,9,5,17,5,9,65,2,2,11,2,2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
fetch :: [Int] -> Int | |
fetch args = | |
let | |
(n : ~(a : ~(b : ~(c : x)))) = args | |
in | |
if n == 1 | |
then a | |
else if n == 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BangPatterns #-} | |
module T where | |
import Control.Concurrent.MVar | |
main = do | |
countMVar <- newMVar (\ count -> count):: IO (MVar (Int -> Int)) | |
let | |
process :: IO () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module T where | |
import Control.Concurrent.MVar | |
main = do | |
countMVar <- newMVar 0 :: IO (MVar Int) | |
let | |
process :: IO () | |
process = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
positiveDecimalBytesToIntegral :: (Integral num, Num num) => L.ByteString -> num | |
positiveDecimalBytesToIntegral = collect0 | |
where | |
collect0 :: (Integral num, Num num) => L.ByteString -> num | |
collect0 bs = case L.uncons bs of | |
Just (byte, bs') -> | |
if 0x30 <= byte && byte <= 0x39 | |
then collect1 (fromIntegral $ byte-0x30) bs' | |
else collect0 bs' | |
Nothing -> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Go 裡面有 struct, 還有指向 Struct 的指標. | |
就是.. 有這樣的東西: | |
type T struct { | |
A int | |
} | |
var t T | |
var p *T | |
然後, 於這兩種 type 要 access member 的時候語法一樣, 也就是: | |
t.A |