Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
108
Task/Simple-database/J/simple-database-1.j
Normal file
108
Task/Simple-database/J/simple-database-1.j
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
HELP=: 0 :0
|
||||
Commands:
|
||||
|
||||
DBNAME add DATA
|
||||
DBNAME display the latest entry
|
||||
DBNAME display the latest entry where CATEGORY contains WORD
|
||||
DBNAME display all entries
|
||||
DBNAME display all entries order by CATEGORY
|
||||
|
||||
1) The first add with new DBNAME assign category names.
|
||||
2) lower case arguments verbatim.
|
||||
3) UPPER CASE: substitute your values.
|
||||
|
||||
Examples, having saved this program as a file named s :
|
||||
$ jconsole s simple.db display all entries
|
||||
$ jconsole s simple.db add "first field" "2nd field"
|
||||
)
|
||||
|
||||
Q=: '''' NB. quote character
|
||||
time=: 6!:0@:('YYYY-MM-DD:hh:mm:ss.sss'"_)
|
||||
|
||||
embed=: >@:{.@:[ , ] , >@:{:@:[
|
||||
assert '(x+y)' -: '()' embed 'x+y'
|
||||
|
||||
Duplicate=: 1 :'#~ m&= + 1 #~ #'
|
||||
assert 0 1 2 3 3 4 -: 3 Duplicate i.5
|
||||
|
||||
prepare=: LF ,~ [: }:@:; (Q;Q,';')&embed@:(Q Duplicate)&.>@:(;~ time)
|
||||
assert (-: }.@:".@:}:@:prepare) 'boxed';'';'li''st';'of';'''strings'''
|
||||
|
||||
categorize=: dyad define
|
||||
i=. x i. y
|
||||
if. (1 (~: #) i) +. i (= #) x do.
|
||||
smoutput 'choose 1 of'
|
||||
smoutput x
|
||||
exit 1
|
||||
end.
|
||||
{. i NB. "index of" frame has rank 1.
|
||||
)
|
||||
assert 0 -: 'abc' categorize 'a'
|
||||
|
||||
loadsdb=: (<'time') (<0 0)} ".;._2@:(1!:1)
|
||||
|
||||
Dispatch=: conjunction define
|
||||
help
|
||||
:
|
||||
commands=. y
|
||||
command=. {. commands
|
||||
x (u`help@.(command(i.~ ;:)n)) }.commands
|
||||
)
|
||||
|
||||
NB. the long fork in show groups (": #~ (1 1 embed (1j1 }:@:# (1 #~ #))))
|
||||
show=: smoutput@:(": #~ 1 1 embed 1j1 }:@:# 1 #~ #)
|
||||
|
||||
in=: +./@:E.
|
||||
assert 'the' in'quick brown fox jumps over the lazy dog'
|
||||
assert 'the'-.@:in'QUICK BROWN FOX JUMPS OVER THE LAZY DOG'
|
||||
|
||||
where=: dyad define
|
||||
'category contains word'=. 3 {. y
|
||||
if. 'contains' -.@:-: contains do.
|
||||
help''
|
||||
exit 1
|
||||
end.
|
||||
i=. x ({.@:[ categorize <@:]) category
|
||||
j=. {: I. ; word&in&.> i {"1 x
|
||||
if. 0 (= #) j do.
|
||||
smoutput 'no matches'
|
||||
else.
|
||||
x (show@:{~ 0&,) j
|
||||
end.
|
||||
)
|
||||
|
||||
entry=: 4 : 0
|
||||
if. a: = y do.
|
||||
show@:({. ,: {:) x
|
||||
else.
|
||||
x ''`where Dispatch'where' y
|
||||
end.
|
||||
)
|
||||
|
||||
latest=: ''`entry Dispatch'entry'
|
||||
the=: ''`latest Dispatch'latest'
|
||||
|
||||
by=: 4 : 0
|
||||
i=. x (categorize~ {.)~ y
|
||||
show ({. , (/: i&{"1)@:}.) x
|
||||
)
|
||||
|
||||
order=: ''`by Dispatch'by'
|
||||
|
||||
entries=: 4 : 0
|
||||
if. a: = y do.
|
||||
show x
|
||||
else.
|
||||
x ''`order Dispatch'order' y
|
||||
end.
|
||||
)
|
||||
|
||||
all=: ''`entries Dispatch'entries'
|
||||
|
||||
help=: smoutput@:(HELP"_)
|
||||
add=: 1!:3~ prepare NB. minimal---no error tests
|
||||
display=: (the`all Dispatch'the all'~ loadsdb)~ NB. load the simple db for some sort of display
|
||||
|
||||
({. add`display Dispatch'add display' }.)@:(2&}.)ARGV
|
||||
|
||||
exit 0
|
||||
13
Task/Simple-database/J/simple-database-2.j
Normal file
13
Task/Simple-database/J/simple-database-2.j
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
D='jconsole s dataflow'
|
||||
|
||||
$D add name expression algebraic rank valence example explanation
|
||||
$D add insert 'f/ y' 'insert f within y' infinite dyad 'sum=: +/' 'continued_fraction=:+`%/'
|
||||
$D add fork '(f g h)y' 'g(f(y),h(y))' infinite monad 'average=: +/ % #' 'sum divided by tally'
|
||||
$D add hook '(f g)y' 'f(y,g(y))' infinite monad '(/: 2&{"1)table' 'sort by third column'
|
||||
$D add hook 'x(f g)y' 'f(x,g(y))' infinite dyad 'display verb in s' 'a reflexive dyadic hook'
|
||||
$D add fork 'x(f g h)y' 'g(f(x,y),h(x,y))' infinite dyad '2j1(+ * -)9 12' 'product of sum and difference'
|
||||
$D add reflexive 'f~ y' 'f(y,y)' infinite monad '^~y' 'y raised to the power of y'
|
||||
$D add passive 'x f~ y' 'f(y,x)' 'ranks of f' dyad '(%~ i.@:>:) 8x' '8 intervals from 0 to 1'
|
||||
$D add atop 'f@g y' 'f(g(y))' 'rank of g' monad '*:@(+/)' 'square the sum'
|
||||
$D add atop 'x f@g y' 'f(g(x,y))' 'rank of g' dyad '>@{.' '(lisp) open the car'
|
||||
$D add 'many more!'
|
||||
76
Task/Simple-database/J/simple-database-3.j
Normal file
76
Task/Simple-database/J/simple-database-3.j
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
$ . input # source the input
|
||||
$ echo $D
|
||||
jconsole s dataflow
|
||||
$ $D display the latest entry
|
||||
┌───────────────────────┬──────────┬──────────┬─────────┬────┬───────┬───────┬───────────┐
|
||||
│time │name │expression│algebraic│rank│valence│example│explanation│
|
||||
│2012-02-07:20:36:54.749│many more!│ │ │ │ │ │ │
|
||||
└───────────────────────┴──────────┴──────────┴─────────┴────┴───────┴───────┴───────────┘
|
||||
$ $D display the latest entry where 'part of speech' contains verb
|
||||
choose 1 of
|
||||
┌────┬────┬──────────┬─────────┬────┬───────┬───────┬───────────┐
|
||||
│time│name│expression│algebraic│rank│valence│example│explanation│
|
||||
└────┴────┴──────────┴─────────┴────┴───────┴───────┴───────────┘
|
||||
$ $D display the latest entry where example contains average
|
||||
┌───────────────────────┬────┬──────────┬────────────┬────────┬───────┬────────────────┬────────────────────┐
|
||||
│time │name│expression│algebraic │rank │valence│example │explanation │
|
||||
│2012-02-07:20:36:54.564│fork│(f g h)y │g(f(y),h(y))│infinite│monad │average=: +/ % #│sum divided by tally│
|
||||
└───────────────────────┴────┴──────────┴────────────┴────────┴───────┴────────────────┴────────────────────┘
|
||||
$ $D display all entries ordre by valence # oops! transposition typo.
|
||||
Commands:
|
||||
|
||||
DBNAME add DATA
|
||||
DBNAME display the latest entry
|
||||
DBNAME display the latest entry where CATEGORY contains WORD
|
||||
DBNAME display all entries
|
||||
DBNAME display all entries order by CATEGORY
|
||||
|
||||
1) The first add with new DBNAME assign category names.
|
||||
2) lower case arguments verbatim.
|
||||
3) UPPER CASE: substitute your values.
|
||||
|
||||
Examples, having saved this program as a file named s :
|
||||
$ jconsole s simple.db display all entries
|
||||
$ jconsole s simple.db add "first field" "2nd field"
|
||||
|
||||
$ $D display all entries order by valence
|
||||
┌───────────────────────┬──────────┬──────────┬─────────────────┬──────────┬───────┬─────────────────┬─────────────────────────────┐
|
||||
│time │name │expression│algebraic │rank │valence│example │explanation │
|
||||
│2012-02-08:23:45:06.539│many more!│ │ │ │ │ │ │
|
||||
│2012-02-08:23:45:06.329│insert │f/ y │insert f within y│infinite │dyad │sum=: +/ │continued_fraction=:+`%/ │
|
||||
│2012-02-08:23:45:06.400│hook │x(f g)y │f(x,g(y)) │infinite │dyad │display verb in s│a reflexive dyadic hook │
|
||||
│2012-02-08:23:45:06.426│fork │x(f g h)y │g(f(x,y),h(x,y)) │infinite │dyad │2j1(+ * -)9 12 │product of sum and difference│
|
||||
│2012-02-08:23:45:06.471│passive │x f~ y │f(y,x) │ranks of f│dyad │(%~ i.@:>:) 8x │8 intervals from 0 to 1 │
|
||||
│2012-02-08:23:45:06.515│atop │x f@g y │f(g(x,y)) │rank of g │dyad │>@{. │(lisp) open the car │
|
||||
│2012-02-08:23:45:06.353│fork │(f g h)y │g(f(y),h(y)) │infinite │monad │average=: +/ % # │sum divided by tally │
|
||||
│2012-02-08:23:45:06.376│hook │(f g)y │f(y,g(y)) │infinite │monad │(/: 2&{"1)table │sort by third column │
|
||||
│2012-02-08:23:45:06.448│reflexive │f~ y │f(y,y) │infinite │monad │^~y │y raised to the power of y │
|
||||
│2012-02-08:23:45:06.493│atop │f@g y │f(g(y)) │rank of g │monad │*:@(+/) │square the sum │
|
||||
└───────────────────────┴──────────┴──────────┴─────────────────┴──────────┴───────┴─────────────────┴─────────────────────────────┘
|
||||
$ $D display all entries
|
||||
┌───────────────────────┬──────────┬──────────┬─────────────────┬──────────┬───────┬─────────────────┬─────────────────────────────┐
|
||||
│time │name │expression│algebraic │rank │valence│example │explanation │
|
||||
│2012-02-08:23:45:06.329│insert │f/ y │insert f within y│infinite │dyad │sum=: +/ │continued_fraction=:+`%/ │
|
||||
│2012-02-08:23:45:06.353│fork │(f g h)y │g(f(y),h(y)) │infinite │monad │average=: +/ % # │sum divided by tally │
|
||||
│2012-02-08:23:45:06.376│hook │(f g)y │f(y,g(y)) │infinite │monad │(/: 2&{"1)table │sort by third column │
|
||||
│2012-02-08:23:45:06.400│hook │x(f g)y │f(x,g(y)) │infinite │dyad │display verb in s│a reflexive dyadic hook │
|
||||
│2012-02-08:23:45:06.426│fork │x(f g h)y │g(f(x,y),h(x,y)) │infinite │dyad │2j1(+ * -)9 12 │product of sum and difference│
|
||||
│2012-02-08:23:45:06.448│reflexive │f~ y │f(y,y) │infinite │monad │^~y │y raised to the power of y │
|
||||
│2012-02-08:23:45:06.471│passive │x f~ y │f(y,x) │ranks of f│dyad │(%~ i.@:>:) 8x │8 intervals from 0 to 1 │
|
||||
│2012-02-08:23:45:06.493│atop │f@g y │f(g(y)) │rank of g │monad │*:@(+/) │square the sum │
|
||||
│2012-02-08:23:45:06.515│atop │x f@g y │f(g(x,y)) │rank of g │dyad │>@{. │(lisp) open the car │
|
||||
│2012-02-08:23:45:06.539│many more!│ │ │ │ │ │ │
|
||||
└───────────────────────┴──────────┴──────────┴─────────────────┴──────────┴───────┴─────────────────┴─────────────────────────────┘
|
||||
$ cat dataflow
|
||||
'2012-02-08:23:45:06.304';'name';'expression';'algebraic';'rank';'valence';'example';'explanation'
|
||||
'2012-02-08:23:45:06.329';'insert';'f/ y';'insert f within y';'infinite';'dyad';'sum=: +/';'continued_fraction=:+`%/'
|
||||
'2012-02-08:23:45:06.353';'fork';'(f g h)y';'g(f(y),h(y))';'infinite';'monad';'average=: +/ % #';'sum divided by tally'
|
||||
'2012-02-08:23:45:06.376';'hook';'(f g)y';'f(y,g(y))';'infinite';'monad';'(/: 2&{"1)table';'sort by third column'
|
||||
'2012-02-08:23:45:06.400';'hook';'x(f g)y';'f(x,g(y))';'infinite';'dyad';'display verb in s';'a reflexive dyadic hook'
|
||||
'2012-02-08:23:45:06.426';'fork';'x(f g h)y';'g(f(x,y),h(x,y))';'infinite';'dyad';'2j1(+ * -)9 12';'product of sum and difference'
|
||||
'2012-02-08:23:45:06.448';'reflexive';'f~ y';'f(y,y)';'infinite';'monad';'^~y';'y raised to the power of y'
|
||||
'2012-02-08:23:45:06.471';'passive';'x f~ y';'f(y,x)';'ranks of f';'dyad';'(%~ i.@:>:) 8x';'8 intervals from 0 to 1'
|
||||
'2012-02-08:23:45:06.493';'atop';'f@g y';'f(g(y))';'rank of g';'monad';'*:@(+/)';'square the sum'
|
||||
'2012-02-08:23:45:06.515';'atop';'x f@g y';'f(g(x,y))';'rank of g';'dyad';'>@{.';'(lisp) open the car'
|
||||
'2012-02-08:23:45:06.539';'many more!'
|
||||
$
|
||||
Loading…
Add table
Add a link
Reference in a new issue