Re: [sqlite] SQL quine using with
Here is one (sorta with inventive rule interpretation): sqlite3 /dev/null 'Error: near "Error": syntax error' Generates the command as output (at least with 3.8.2 from ports on FreeBSD): Error: near "Error": syntax errors Thank you! [takes bow] On Mar 8, 2014 12:16 PM, "Zsbán Ambrus" wrote: > And here's a quine which simply concatenates six named strings a lot of > times. > > > SELECT > ab||a||a||a||a||aa||b||a||b||a||bb||b|| > a||aa||a||aa||aa||b||a||bb||a||bb||bb||b|| > a||ab||a||aa||bb||b||a||ba||a||bb||aa||ba > FROM(SELECTa,','b,'a'aa,'b'bb,'SELECT > ab||a||a||a||a||aa||b||a||b||a||bb||b|| > a||aa||a||aa||aa||b||a||bb||a||bb||bb||b|| > a||ab||a||aa||bb||b||a||ba||a||bb||aa||ba > FROM(SELECT'ab,');'ba); > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQL quine using with
And here's a quine which simply concatenates six named strings a lot of times. SELECT ab||a||a||a||a||aa||b||a||b||a||bb||b|| a||aa||a||aa||aa||b||a||bb||a||bb||bb||b|| a||ab||a||aa||bb||b||a||ba||a||bb||aa||ba FROM(SELECTa,','b,'a'aa,'b'bb,'SELECT ab||a||a||a||a||aa||b||a||b||a||bb||b|| a||aa||a||aa||aa||b||a||bb||a||bb||bb||b|| a||ab||a||aa||bb||b||a||ba||a||bb||aa||ba FROM(SELECT'ab,');'ba); ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQL quine using with
Anyway, here's a different quine using the replace function. SELECT replace(s,char(33),)||s||'''s);'FROM(SELECT'SELECT replace(s,char(33),)||s||!!!s);!FROM(SELECT!'s); ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQL quine using with
On 03/08/2014 08:53 PM, Kees Nuyt wrote: Someone called zzo38 posted a quine (self-replicating program) on Internet Relay Chat in network: Freenode, channel: #sqlite [2014-03-08 11:01:59] < zzo38> I made a quine program in SQL. [2014-03-08 11:02:10] < zzo38> with q(q) as (select 'with q(q) as (select ''#'') select replace(q,x''23'',replace(,)) from q;') select replace(q,x'23',replace(q,,'')) from q; [2014-03-08 11:02:52] < zzo38> Do you like quine program in SQL? [2014-03-08 11:03:06] < zzo38> Maybe do you have a better (shorter) one? Note: SQL preferably written as a oneliner References: http://en.wikipedia.org/wiki/Quine_(computing) http://sqlite.org/lang_with.html Enjoy! SELECT REPLACE(q, 8-8, quote(q)) FROM (SELECT 'SELECT REPLACE(q, 8-8, quote(q)) FROM (SELECT 0 AS q);' AS q); ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQL quine using with
I have a favourite general method to write a quine in any programming language. This involves a list of strings and a list of numeric indexes. The second list is used to subscript into the first list, and the found strings are then extracted. This is possible in sqlite3, but comes out particularly ugly. The reasons for the ugliness is mostly that it's not easy to concatenate a list of strings. The group_concat function doesn't work, because you can't guarantee the order it concatenates the strings. Anyway, I show my solution in the bottom of this mail. Ambrus CREATE TABLE pt(p); INSERT INTO pt VALUES (),('),('),('CREATE TABLE pt(p); INSERT INTO pt VALUES ('),('); CREATE TABLE nt(n); INSERT INTO nt VALUES (3),(1),(1),(1),(1),(2),(1),(2),(1),(2),(1),(3),(1),(2), (1),(4),(1),(2),(1),(5),(1),(4),(1),(1),(5); CREATE TABLE rt(r); INSERT INTO rt VALUES ('),('); CREATE TABLE mt(m); CREATE TRIGGER mg AFTER INSERT ON mt BEGIN UPDATE rt SET r = r || new.m; END; INSERT INTO mt SELECT p FROM pt, nt WHERE pt.oid = n; SELECT r FROM rt;'); CREATE TABLE nt(n); INSERT INTO nt VALUES (3),(1),(1),(1),(1),(2),(1),(2),(1),(2),(1),(3),(1),(2), (1),(4),(1),(2),(1),(5),(1),(4),(1),(1),(5); CREATE TABLE rt(r); INSERT INTO rt VALUES (''); CREATE TABLE mt(m); CREATE TRIGGER mg AFTER INSERT ON mt BEGIN UPDATE rt SET r = r || new.m; END; INSERT INTO mt SELECT p FROM pt, nt WHERE pt.oid = n; SELECT r FROM rt; ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users