forum-msg-id-135422-edit
Original date:2021-01-09 11:56:55 Edited by: petelomax Subject: Re: wikipedia draft
Filtering:
function odd(integer a) return remainder(a,2)=1 end function function even(integer a) return remainder(a,2)=0 end function ?filter(tagset(10),odd) -- ==> {1,3,5,7,9} ?filter(tagset(10),even) -- ==> {2,4,6,8,10}
the above, wp-ready:
Filtering: <font color="#008080">function</font><font color="#000000"> odd</font><font color="#0000FF">(</font><font color="#004080">integer</font><font color="#000000"> a</font><font color="#0000FF">)</font><font color="#008080"> return</font><font color="#7060A8"> remainder</font><font color="#0000FF">(</font><font color="#000000">a</font><font color="#0000FF">,</font><font color="#000000">2</font><font color="#0000FF">)=</font><font color="#000000">1</font><font color="#008080"> end function function</font><font color="#000000"> even</font><font color="#0000FF">(</font><font color="#004080">integer</font><font color="#000000"> a</font><font color="#0000FF">)</font><font color="#008080"> return</font><font color="#7060A8"> remainder</font><font color="#0000FF">(</font><font color="#000000">a</font><font color="#0000FF">,</font><font color="#000000">2</font><font color="#0000FF">)=</font><font color="#000000">0</font><font color="#008080"> end function </font><font color="#0000FF">?</font><font color="#5E005E">filter</font><font color="#0000FF">(</font><font color="#5E005E">tagset</font><font color="#800000">(</font><font color="#000000">10</font><font color="#800000">)</font><font color="#0000FF">,</font><font color="#000000">odd</font><font color="#0000FF">) </font><font color="#000080"><i> -- ==> {1,3,5,7,9} </i></font><font color="#0000FF">?</font><font color="#5E005E">filter</font><font color="#0000FF">(</font><font color="#5E005E">tagset</font><font color="#800000">(</font><font color="#000000">10</font><font color="#800000">)</font><font color="#0000FF">,</font><font color="#000000">even</font><font color="#0000FF">) </font><font color="#000080"><i> -- ==> {2,4,6,8,10} </i></font>
Specify what versions and/or operating systems are required to run the source code:
requires("0.8.2") -- crashes on 0.8.1 and earlier requires(WINDOWS) -- crashes on Linux requires(64) -- crashes on 32-bit
In the latter case, if you try to run a 64-bit-only program with a 32-bit interpreter, it will try to locate a suitable 64-bit interpreter and offer to re-run it with that (and vice-versa, for instance the older arwen and win32lib libraries are 32-bit only).
the above, wp-ready:
Specify what versions and/or operating systems are required to run the source code: <font color="#5E005E">requires</font><font color="#0000FF">(</font><font color="#008000">"0.8.2"</font><font color="#0000FF">) </font><font color="#000080"><i> -- crashes on 0.8.1 and earlier</i></font> <font color="#5E005E">requires</font><font color="#0000FF">(</font><font color="#004600">WINDOWS</font><font color="#0000FF">) </font><font color="#000080"><i> -- crashes on Linux</i></font> <font color="#5E005E">requires</font><font color="#0000FF">(</font><font color="#000000">64</font><font color="#0000FF">) </font><font color="#000080"><i> -- crashes on 32-bit</i></font></html> In the latter case, if you try to run a 64-bit-only program with a 32-bit interpreter, it will try to locate a suitable 64-bit interpreter and offer to re-run it with that (and vice-versa, for instance the older arwen and win32lib libraries are 32-bit only).
Unit testing:
test_equal(2+2,4,"2+2 is not 4 !!!!") test_summary()
If all goes well, no output is shown, and the program carries on normally.
You can easily force a summary to be output, quietly create a logfile, etc.
the above, wp-ready:
Unit testing: <font color="#5E005E">test_equal</font><font color="#0000FF">(</font><font color="#000000">2</font><font color="#0000FF">+</font><font color="#000000">2</font><font color="#0000FF">,</font><font color="#000000">4</font><font color="#0000FF">,</font><font color="#008000">"2+2 is not 4 !!!!"</font><font color="#0000FF">)</font> <font color="#5E005E">test_summary</font><font color="#0000FF">()</font> If all goes well, no output is shown, and the program carries on normally.<br> You can easily force a summary to be output, quietly create a logfile, etc.
PS I'm colouring code via <block select> Edita\Edit\Clipboard\Copy with HTML, but then I have to delete <head> etc and re-space every line. I'm more than happy to do that for any fragment you post here, including the existing examples on wp.
Not Categorized, Please Help
|