討論串[閒聊] 不使用if的寫法
共 18 篇文章

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者dryman (dryman)時間12年前 (2013/01/11 06:45), 編輯資訊
0
0
1
內容預覽:
應該是最短的寫法in perl:. $i = 1;. $j = 2;. print+(No,Yes)[$i==1],$/; # ==> Yes. print+(No,Yes)[$j==1],$/; # ==> No. 用到了bare words, 只當作間格用的+, ()是array literal
(還有92個字)

推噓2(2推 0噓 1→)留言3則,0人參與, 最新作者neutrino (十年一夢)時間12年前 (2013/01/11 03:11), 編輯資訊
0
0
0
內容預覽:
變化一下. uint64_t yesno = 0x0073657900006f6e >> ((i == 1) << 5);. printf ( "%s\n", (char*) &yesno );. operator個數 6個 -> 3個. 編輯: neutrino 來自: 218.211.32.

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者darkgerm (黑駿)時間12年前 (2013/01/11 02:54), 編輯資訊
0
0
0
內容預覽:
void handler(int signo) {. printf("yes\n");. exit(0);. }. int main() {. int i = 1;. signal(SIGALRM, handler);. alarm(i);. sleep(1);. printf("no\n");.

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者xatier (xatier)時間12年前 (2013/01/11 02:29), 編輯資訊
0
0
0
內容預覽:
Pattern matching in Standard ML. Standard ML of New Jersey v110.75 [built: Wed Jan 2 11:17:54 2013]. - fun foo 1 = "yes". = | foo _ = "no";. val foo =
(還有26個字)

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者xatier (xatier)時間12年前 (2013/01/11 02:21), 編輯資訊
0
0
0
內容預覽:
in Perl. my @a = ("no", "yes", ("no") x 65533);. say $a[$i];. --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From: 140.113.0.213.