Simple database: Difference between revisions
Content added Content deleted
(Added PicoLisp) |
m (Formatting) |
||
Line 8: | Line 8: | ||
You should track the following details: |
You should track the following details: |
||
* A description of the item. ( |
* A description of the item. (e.g., title, name) |
||
* A category or tag (genre, topic, relationship |
* A category or tag (genre, topic, relationship such as “friend” or “family”) |
||
* A date (either the date when the entry was made or some other date that is meaningful |
* A date (either the date when the entry was made or some other date that is meaningful, like the birthday); the date may be generated or entered manually |
||
* Other optional fields |
* Other optional fields |
||
Line 19: | Line 19: | ||
* Print all entries sorted by a date |
* Print all entries sorted by a date |
||
The category may be realized as a tag or as structure (making all entries in that category subitems) |
The category may be realized as a tag or as structure (by making all entries in that category subitems) |
||
The |
The file format on disk should be human readable, but it need not be standardized. A natively available format that doesn't need an external library is preferred. Avoid developing your own format however if you can use an already existing one. If there is no existing format available pick one of: [[JSON]], [[S-Expressions]], [[YAML]], or [[wp:Comparison_of_data_serialization_formats|others]]. |
||
See also [[Take notes on the command line]] for a related task. |
See also [[Take notes on the command line]] for a related task. |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
sbcl --script watch.lisp |
sbcl --script watch.lisp |
||
Without arguments the function <code>(watch-list)</code> is invoked to show the last episode of each series. |
|||
With the argument <code>add</code> the function <code>(watch-add)</code> will allow you to add a new episode with series name, episode title, episode number and date watched. If the series does not yet exist, you will be asked if you want to create it. |
|||
⚫ | |||
⚫ | |||
<lang lisp>(defvar db nil) |
<lang lisp>(defvar db nil) |
||
Line 231: | Line 230: | ||
=={{header|Pike}}== |
=={{header|Pike}}== |
||
{{trans|Common Lisp}} |
|||
an almost direct translation from common lisp: |
|||
<lang Pike>mapping db = ([]); |
<lang Pike>mapping db = ([]); |
||
Line 388: | Line 387: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<lang ruby>require 'date' |
<lang ruby>require 'date' |
||
require 'json' |
require 'json' |