2008-10-01から1ヶ月間の記事一覧

Parsec.Combinator:endBy1

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = endBy1 letter (char ',') run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ;…

C API、lua_pushvfstring()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102400 -llua50 2008102400.c */ #include <stdio.h> #include <stdarg.h> #include <lua.h> void my_pushfstring(lua_State *L, char *fmt, ...) { va_list args; va_start(args, fmt); lua_pushvfstring(L, fmt, args); va_end(args</lua.h></stdarg.h></stdio.h>…

ActiveSupport、Time#compare_with_coercion

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).compare_with_coercion(Time.local(2008, 12, 31)) => 0 >> Time.local(2008, 12, 31).compare_with_coercion(Time.local(2008, 12, 30)) => 1 >> Time.loc…

Commons Lang、StringUtils.isAlpha()

まんま import org.apache.commons.lang.StringUtils; public class C2008102300 { public static void main(String[] args) { System.out.println(StringUtils.isAlpha(null)); System.out.println(StringUtils.isAlpha("")); System.out.println(StringUti…

Parsec.Combinator:endBy

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = endBy letter (char ',') run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ; …

C API、lua_pushfstring()

機能は限定されているらしい。そんなので嬉しいのか?(メモリ管理を考えなくて良いのが楽?) /* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102300 -llua50 2008102300.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_pu</lua.h></stdio.h>…

ActiveSupport、Time#change

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).change(:month => 1) => Thu Jan 31 00:00:00 +0900 2008 >> Time.local(2008, 12, 31).change(:day => 1) => Mon Dec 01 00:00:00 +0900 2008 >> Time.loc…

Commons Lang、StringUtils.indexOfDifference()

まんま import org.apache.commons.lang.StringUtils; public class C2008102200 { public static void main(String[] args) { System.out.println(StringUtils.indexOfDifference(null, null)); System.out.println(StringUtils.indexOfDifference("", ""))…

Parsec.Combinator:sepBy1

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = sepBy1 letter (char ',') run :: Show a => Parser a -> String -> IO () run p input = case (parse p "" input) of Left err -> do{ putStr "parse error at " ;…

C API、lua_lessthan()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102200 -llua50 2008102200.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_pushnumber(L, 10); lua_pushnumber(L, 10); printf("%d\n", lua_lessthan(L, -1, -2)); lua_pu</lua.h></stdio.h>…

ActiveSupport、Time#beginning_of_year, Time#at_beginning_of_year

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).beginning_of_year => Tue Jan 01 00:00:00 +0900 2008 >> Time.local(2008, 12, 31).at_beginning_of_year => Tue Jan 01 00:00:00 +0900 2008

Commons Lang、StringUtils.indexOfAnyBut()

まんま import org.apache.commons.lang.StringUtils; public class C2008102100 { public static void main(String[] args) { char[] e = {}; char[] za = {'z', 'a'}; char[] ab = {'a', 'b'}; char[] foo = {'f', 'o', 'o'}; System.out.println(StringUt…

Parsec.Combinator:sepBy

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = sepBy letter (char ',') test2 :: Parser [String] test2 = sepBy (many1 letter) (char ',') test3 = (flip sepBy) (char ',') run :: Show a => Parser a -> Str…

C API、lua_rawequal()

lua_equal() と差異のあるコードが作れなかった。メタメソッドを変更していないと差が出ないのかな? /* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102100 -llua50 2008102100.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open()</lua.h></stdio.h>…

ActiveSupport、Time#beginning_of_week, Time#at_beginning_of_week, Time#monday

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).beginning_of_week => Mon Dec 29 00:00:00 +0900 2008 >> Time.local(2008, 12, 31).monday => Mon Dec 29 00:00:00 +0900 2008 >> Time.local(2008, 12, …

Commons Lang、StringUtils.indexOfAny()

まんま import org.apache.commons.lang.StringUtils; public class C2008102000 { public static void main(String[] args) { char[] ce = {}; char[] ca = {'a'}; char[] cza = {'z', 'a'}; char[] cby = {'b', 'y'}; char[] cz = {'z'}; String[] se = {"…

Parsec.Combinator:skipMany1

module Main where import Text.ParserCombinators.Parsec test1 :: Parser () test1 = skipMany1 letter test2 :: Parser String test2 = do { skipMany1 space ; cs <- many letter ; skipMany1 space ; return cs } run :: Show a => Parser a -> String …

C API、lua_equal()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008102000 -llua50 2008102000.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; L = lua_open(); lua_pushnumber(L, 10); lua_pushnumber(L, 10); printf("%d\n", lua_equal(L, -1, -2)); lua_pushn</lua.h></stdio.h>…

ActiveSupport、Time#beginning_of_quarter, Time#at_beginning_of_quarter

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).beginning_of_quarter => Wed Oct 01 00:00:00 +0900 2008 >> Time.local(2008, 12, 31).at_beginning_of_quarter => Wed Oct 01 00:00:00 +0900 2008 >> T…

Commons Lang、StringUtils.indexOf()

まんま import org.apache.commons.lang.StringUtils; public class C2008101900 { public static void main(String[] args) { System.out.println(StringUtils.indexOf(null, 'a')); System.out.println(StringUtils.indexOf("", 'a')); System.out.println…

Parsec.Combinator:skipMany

module Main where import Text.ParserCombinators.Parsec test1 :: Parser () test1 = skipMany letter test2 :: Parser String test2 = many letter test3 :: Parser () test3 = do { skipMany space ; many letter ; skipMany space } test4 :: Parser St…

C API、lua_typename()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008101900 -llua50 2008101900.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; /*L = lua_open();*/ printf("%s\n", lua_typename(L, LUA_TNIL)); printf("%s\n", lua_typename(L, LUA_TNUMBER)); </lua.h></stdio.h>…

ActiveSupport、Time#beginning_of_month, Time#at_beginning_of_month

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).beginning_of_month => Mon Dec 01 00:00:00 +0900 2008 >> Time.local(2008, 12, 31).at_beginning_of_month => Mon Dec 01 00:00:00 +0900 2008

Commons Lang、StringUtils.getLevenshteinDistance()

まんま import org.apache.commons.lang.StringUtils; public class C2008101800 { public static void main(String[] args) { //System.out.println(StringUtils.getLevenshteinDistance(null, "")); //System.out.println(StringUtils.getLevenshteinDista…

Parsec.Combinator:many1

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = many1 letter test2 :: Parser String test2 = many1 letter "message for test2" run :: Show a => Parser a -> String -> IO () run p input = case (parse p ""…

C API、LUA_TTHREAD, lua_newthread(), lua_tothread()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008101800 -llua50 2008101800.c */ #include <stdio.h> #include <lua.h> int main(void) { lua_State *L; lua_State *LT; L = lua_open(); printf("%d\n*\n", LUA_TTHREAD); lua_newthread(L); printf("%d\n", lua_type(L, -</lua.h></stdio.h>…

ActiveSupport、Time#beginning_of_day, Time#at_beginning_of_day, Time#midnight, Time#at_midnight

>> require "rubygems" => true >> require "active_support" => true >> Time.local(2008, 12, 31).beginning_of_day => Wed Dec 31 00:00:00 +0900 2008 >> Time.local(2008, 12, 31).ago(1).beginning_of_day => Tue Dec 30 00:00:00 +0900 2008 >> Time.…

Commons Lang、StringUtils.equalsIgnoreCase()

まんま import org.apache.commons.lang.StringUtils; public class C2008101700 { public static void main(String[] args) { System.out.println(StringUtils.equalsIgnoreCase(null, null)); System.out.println(StringUtils.equalsIgnoreCase(null, "abc…

Parsec.Combinator:many

module Main where import Text.ParserCombinators.Parsec test1 :: Parser String test1 = many letter test2 :: Parser String test2 = many letter "message for test2" test3 :: Parser String test3 = many digit "message for test3" run :: Show a …

C API、LUA_TUSERDATA, lua_newuserdata(), lua_isuserdata(), lua_touserdata()

/* * $ gcc -Wall -W -I/usr/include/lua50 -o 2008101700 -llua50 2008101700.c */ #include <stdio.h> #include <lua.h> typedef struct foo { int x; int y; } FOO; int main(void) { lua_State *L; FOO *foo; L = lua_open(); printf("%d\n*\n", LUA_TUSERDATA); foo = l</lua.h></stdio.h>…