<@ OMT>-------------------------- |
|
<@ LETVARLIT>string|\n</@> |
<@ OMT>two characters, \ and n</@> |
<@ LETVARLIT>string|Jon 'Maddog' Orwant</@> |
<@ OMT>literal single quotes</@> |
<@ OMT>-------------------------- |
|
<@ LETVARLIT>string| |
<@ OMT>a "newline" character</@> |
<@ LETVARKEY>string|__Newline</@> |
<@ OMT>a "newline" character</@> |
<@ LETVARLIT>string|Jon "Maddog" Orwant</@> |
<@ OMT>literal double quotes</@> |
<@ LETVAREXPLIT>string|Jon &pipe;Maddog&pipe; Orwant</@> |
<@ OMT>Because | and <@ and </@ are significant there are ways to quote them</@> |
<@ LETVARLIT>Bruce Goose|布魯斯鵝</@> |
<@ OMT>a variable name containing spaces. |
<@ OMT>-------------------------- |
|
<@ OMT>Multi-line strings. |
|
<@ LETVARLIT>a| |
|
<@ LETVARLIT>string|This is a multiline string |
|
<@ OMT>-------------------------- |
Past (20 years or so) and present code. A variety of languages and platforms. Some gems. More gravel. Some useful stuff and some examples of how not to do it.
Showing posts with label PLEAC. Show all posts
Showing posts with label PLEAC. Show all posts
Saturday, December 12, 2009
[Protium] PLEAC 1.0
[Protium] PLEAC in Protium
PLEAC, for those unfamiliar with it, is the Programming Language Examples Alike Cookbook. This is a brilliant site which takes examples of Perl, given in Perl Cookbook by Christiansen and Torkington, and invites contributors to demonstrate how other languages implement the same functionality. Many languages are in the process of being compared and contrasted in this way, including Python, Ruby, Tcl and Haskell. All manner of functionality is covered, from Strings, Numbers, Dates and Times through to Internet Services, CGI Programming and Web Automation.
For the next few postings I am going to do a PLEAC for Protium. You won't find Protium on PLEAC's pages because PLEAC is limited to open-source languages. Protium is proprietary and closed-source (at present.)
The challenge with converting from Perl to Protium is similar to that faced by linguists translating from one human language to another: do you translate the sense of the utterance, or do you just translate word for word. For example, the Tok Pisin word rabisman literally means "rubbish man". However, it is almost never used that way. Instead it often carries the sense of "fool" or "good-for-nothing." So when converting the Perl to Protium, I've tried to give the sense of the Perl, rather than follow it line for line or word for word.
There will be the odd non-PLEAC posting, but I will try to work my way through the entire PLEAC, all 300K's worth.
For the next few postings I am going to do a PLEAC for Protium. You won't find Protium on PLEAC's pages because PLEAC is limited to open-source languages. Protium is proprietary and closed-source (at present.)
The challenge with converting from Perl to Protium is similar to that faced by linguists translating from one human language to another: do you translate the sense of the utterance, or do you just translate word for word. For example, the Tok Pisin word rabisman literally means "rubbish man". However, it is almost never used that way. Instead it often carries the sense of "fool" or "good-for-nothing." So when converting the Perl to Protium, I've tried to give the sense of the Perl, rather than follow it line for line or word for word.
There will be the odd non-PLEAC posting, but I will try to work my way through the entire PLEAC, all 300K's worth.
Tuesday, October 23, 2007
[Protium] Splitting
Here's a short script for splitting a file. The file in this case is the perl language data file from the PLEAC website. pleac_perl.data contains sections marked with "# ^^PLEAC^^_" followed by a number. The section applies until the next section is marked. The script splits each section out of pleac_perl.data into pleac_perl_number.p. I'm working through these files and re-expressing the intent of the perl code in Protium.
The code may be described as follows:
© Copyright Bruce M. Axtens, 2007
The code may be described as follows:
- Define a work area, or alias, for the data file, calling it 'pleac'.
- Open the text file within that work area, using define-file-lit.
- Start a loop which iterates through an enumeration of the lines of data in the work area.
- Let a variable contain the data in the current line of the work area.
- Test whether the regular expression works for the current line.
- If it does work, let a variable contain the number found, ...
- ... turn off any output redirection, ...
- ... and redirect output to the file 'pleac_perl_' + the number found (in the same directory as the script).
- End of the if.
- Output the contents of the line.
- End of the iteration.
© Copyright Bruce M. Axtens, 2007
Subscribe to:
Posts (Atom)