bf            SQL       bleis-tiftFebruary 26, 2011
id:bleis-tift / @bleis
id:bleis-tift / @bleis
id:bleis-tift / @bleisSQL                      CTE
id:bleis-tift / @bleisSQL                      CTE
id:bleis-tift / @bleisSQL                      CTE
SQL
SQL
SQL   bf
SQL   bfPL/SQL   T-SQL
SQL   bf         PL/SQL    T-SQLSELECT        bf
CTE
CTE
CTE
CTE
CTECommon Table Expression
CTECommon Table ExpressionSQL99
CTECommon Table ExpressionSQL99
CTECommon Table ExpressionSQL99
CTECommon Table ExpressionSQL99           SELECT
SELECT *FROM  (SELECT 1 AS n UNION ALL   SELECT 3) T;
SELECT *FROM  (SELECT 1 AS n UNION ALL   SELECT 3) T;13
SELECT *FROM  (SELECT 1 AS n UNION ALL   SELECT 3) T;CTEWITH T(n) AS (  SELECT 1 UNION ALL  SELECT 3)SELECT * FROM T;
CTE
CTECTE     CTE
CTECTE             CTE      SQL   SELECT
CTEWITH Hoge(n) AS (  SELECT 1 UNION ALL  SELECT n + 1 FROM Hoge  WHERE n < 3)SELECT * FROM Hoge;
CTEWITH Hoge(n) AS (  SELECT 1 UNION ALL  SELECT n + 1 FROM Hoge  WHERE n < 3)SELECT * FROM Hoge;123
bf
bfBrainfuck
bfBrainfuck
bfBrainfuck
bfBrainfuck
bf   CTE
Ruby
Ruby       CTE
Ruby       CTE       CTE
Ruby             CTE             CTE       CTE
Ruby             CTE             CTE       CTE
Ruby                  CTE                  CTE            CTE       NE
Ruby                  CTE                  CTE            CTE       NE
WITH                                                                                 , Eval(id, array, ptr, input_pgm, crn...
Q.
Q.A.
Q.A.
Q.A.
Q.A.
SQL
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
Upcoming SlideShare
Loading in …5
×

そうだ、bf処理系作ろう!もちろんSQLで!

2,644 views

Published on

名古屋Reject会議での発表資料です。

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,644
On SlideShare
0
From Embeds
0
Number of Embeds
41
Actions
Shares
0
Downloads
3
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

そうだ、bf処理系作ろう!もちろんSQLで!

  1. 1. bf SQL bleis-tiftFebruary 26, 2011
  2. 2. id:bleis-tift / @bleis
  3. 3. id:bleis-tift / @bleis
  4. 4. id:bleis-tift / @bleisSQL CTE
  5. 5. id:bleis-tift / @bleisSQL CTE
  6. 6. id:bleis-tift / @bleisSQL CTE
  7. 7. SQL
  8. 8. SQL
  9. 9. SQL bf
  10. 10. SQL bfPL/SQL T-SQL
  11. 11. SQL bf PL/SQL T-SQLSELECT bf
  12. 12. CTE
  13. 13. CTE
  14. 14. CTE
  15. 15. CTE
  16. 16. CTECommon Table Expression
  17. 17. CTECommon Table ExpressionSQL99
  18. 18. CTECommon Table ExpressionSQL99
  19. 19. CTECommon Table ExpressionSQL99
  20. 20. CTECommon Table ExpressionSQL99 SELECT
  21. 21. SELECT *FROM (SELECT 1 AS n UNION ALL SELECT 3) T;
  22. 22. SELECT *FROM (SELECT 1 AS n UNION ALL SELECT 3) T;13
  23. 23. SELECT *FROM (SELECT 1 AS n UNION ALL SELECT 3) T;CTEWITH T(n) AS ( SELECT 1 UNION ALL SELECT 3)SELECT * FROM T;
  24. 24. CTE
  25. 25. CTECTE CTE
  26. 26. CTECTE CTE SQL SELECT
  27. 27. CTEWITH Hoge(n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM Hoge WHERE n < 3)SELECT * FROM Hoge;
  28. 28. CTEWITH Hoge(n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM Hoge WHERE n < 3)SELECT * FROM Hoge;123
  29. 29. bf
  30. 30. bfBrainfuck
  31. 31. bfBrainfuck
  32. 32. bfBrainfuck
  33. 33. bfBrainfuck
  34. 34. bf CTE
  35. 35. Ruby
  36. 36. Ruby CTE
  37. 37. Ruby CTE CTE
  38. 38. Ruby CTE CTE CTE
  39. 39. Ruby CTE CTE CTE
  40. 40. Ruby CTE CTE CTE NE
  41. 41. Ruby CTE CTE CTE NE
  42. 42. WITH , Eval(id, array, ptr, input_pgm, crnt, stdout, stdin) AS ( Input(id, bf_program, stdin) AS ( SELECT SELECT 0, id>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++ , CAST(REPLICATE(CHAR(0), 5000) AS char(5000))++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]> , 1++++++++[<++++>-]<+.[-]++++++++++., , bf_program ) , 1, BracketTableSrc(id, open_bracket_pos, close_bracket_pos, stack, src, crnt) AS ( , CAST( AS nvarchar(max)) SELECT , stdin id FROM , 0 Input , 0 UNION ALL , CAST( AS varchar(max)) SELECT , bf_program id , 1 , CAST( FROM CASE SUBSTRING(input_pgm, crnt, 1) Input WHEN + THEN STUFF(array, ptr, 1, CHAR(ASCII(SUBSTRING(array, ptr, 1)) + 1)) UNION ALL WHEN - THEN STUFF(array, ptr, 1, CHAR(ASCII(SUBSTRING(array, ptr, 1)) - 1)) SELECT WHEN , THEN STUFF(array, ptr, 1, LEFT(stdin, 1)) id ELSE array , CASE LEFT(src, 1) END WHEN ] THEN CAST(LEFT(stack, CHARINDEX( , stack, 1)) AS int) AS char(5000)) ELSE 0 , CASE SUBSTRING(input_pgm, crnt, 1) END WHEN > THEN ptr + 1 , CASE LEFT(src, 1) WHEN < THEN ptr - 1 WHEN ] THEN crnt ELSE ptr ELSE 0 END END , input_pgm , CASE LEFT(src, 1) , CASE SUBSTRING(input_pgm, crnt, 1) WHEN [ THEN CAST(crnt AS varchar(4)) + + stack WHEN [ THEN CASE ASCII(SUBSTRING(array, ptr, 1)) WHEN ] THEN SUBSTRING(stack, CHARINDEX( , stack, 1) + 1, LEN(stack)) WHEN 0 THEN (SELECT close_bracket_pos FROM BracketTable ELSE stack WHERE Eval.id = BracketTable.id AND open_bracket_pos = crnt) + 1 END ELSE crnt + 1 , SUBSTRING(src, 2, LEN(src)) END , crnt + 1 WHEN ] THEN (SELECT open_bracket_pos FROM BracketTable FROM WHERE Eval.id = BracketTable.id AND close_bracket_pos = crnt) BracketTableSrc ELSE crnt + 1 WHERE END src <> , CASE SUBSTRING(input_pgm, crnt, 1) ) WHEN . THEN stdout + SUBSTRING(array, ptr, 1), BracketTable(id, open_bracket_pos, close_bracket_pos) AS ( ELSE stdout SELECT END id , CASE SUBSTRING(input_pgm, crnt, 1) , open_bracket_pos WHEN , THEN SUBSTRING(stdin, 2, LEN(stdin)) , close_bracket_pos ELSE stdin FROM END BracketTableSrc FROM WHERE Eval open_bracket_pos <> 0 WHERE AND close_bracket_pos <> 0 crnt <= LEN(input_pgm) ) ) , Result(id, stdout) AS ( SELECT id , stdout FROM Eval P WHERE crnt = (SELECT MAX(crnt) FROM Eval C WHERE P.id = C.id) ) SELECT * FROM Result ORDER BY id OPTION (MAXRECURSION 0)
  43. 43. Q.
  44. 44. Q.A.
  45. 45. Q.A.
  46. 46. Q.A.
  47. 47. Q.A.
  48. 48. SQL

×