Created
July 26, 2013 15:20
-
-
Save zakky-dev/6089726 to your computer and use it in GitHub Desktop.
コンパイルは通っているようですが何故……。
This file contains hidden or 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
import std.array; | |
bool binarySearch(T)(T[] input, T value) { | |
if(input.empty) { | |
return false; | |
} | |
auto i = input.length / 2; | |
auto mid = input[i]; | |
if(mid > value) return binarySearch(input[0 .. i], value); | |
if(mid < value) return binarySearch(input[i .. $], value); | |
return true; | |
} | |
unittest { | |
assert(binarySearch([1,3,5,7,9,11,13,15,17,19,21], 21)); | |
assert(!binarySearch([1,3,5,7,9,11,13,15,17,19,21], 2)); | |
} | |
/* | |
/home/zakky/dmd2/linux/bin64/../lib64/libphobos2.a(dmain2_44d_1a5.o): 関数 `main' 内: | |
src/rt/dmain2.d:(.text.main+0xa): `_Dmain' に対する定義されていない参照です | |
collect2: エラー: ld はステータス 1 で終了しました | |
--- errorlevel 1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
叩くコマンドをミスしてました。
dmd -unittest -main -run binary.d
なら大丈夫のようです。
ただしバグが仕込まれている……。