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
;;---- common-functions ---- | |
(defun filter (pred lst) | |
"引数リストlstの要素の中から、predが成立しない要素を取り除いたリストを返す" | |
(cond ((null lst) nil) | |
((funcall pred (car lst)) | |
(cons (car lst) (filter pred (cdr lst)))) | |
(t (filter pred (cdr lst))))) | |
(defun is_~filep (x) | |
"~が含まれる要素の場合、tを返す" |
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
#include <stdio.h> | |
#include <stdbool.h> | |
#define ZIG 1 | |
#define NONE 0 | |
#define ZAG -1 | |
bool is_zigzag(char* s) { | |
int mode = NONE; | |
char prev = '\0'; | |
for(int i = 0; s[i] != '\0'; i++) { |
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
(define (mytimes n val) | |
(if (= n 1) (list val) | |
(append (list val) (mytimes (- n 1) val)))) |
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
var q = function(){/* | |
SELECT '"' + FB.hogehoge + '","' + FB.fugafuga + '","' + IsNull(ABCD.piyopiyo, ' ') + '"' AS Line | |
FROM FooBar AS FB | |
INNER JOIN ABCDE | |
ON FB.Id = ABCD.foobarId | |
AND ABCD.Name = '$1' | |
AND FB.Active = $2 | |
*/}.toString().split("\n").slice(1,-1).join("\n"); | |
strSQL = q.replace('$1', parameter1) |
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
# nilの混じった配列 | |
ary = [1,2,3,nil,4,5,6,nil,7,8,9].shuffle | |
## => [2, 6, 3, nil, 4, nil, 5, 1, 8, 9, 7] | |
# 普通に、例えばto_iしてソートすると、nil.to_iは0なので頭の方に固まっちゃう | |
ary.sort_by {|n| n.to_i} | |
## => [nil, nil, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
# なので、nilの場合にはINFINITYとして扱うようにしてやると、後ろに固められる | |
ary.sort_by{ |i| i || Float::INFINITY} |
OlderNewer