Version 19 of scratch

Updated 2024-03-26 20:28:52 by gold

gold Replay old scratch page on TCL Wiki. checking end of line issues here.

This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, gold 20Aug2020


Preface


gold Update 3/7/2024. Here are some calculations with Pseudocode outline reference to TCL Procedures.



gold Update 3/7/2024. The author is retired engineer on Windows 10 and no longer has proofing access to Unix machines. Unix is respected after use of so many decades in engineering, but my wings are lost. I did find a useful online IDE, jdoodle. I can paste from a text file, edit, and run an output using this online IDE.



Introduction



Not a Replacement for TCL Core


This page on developing pseudocode examples and one line procedures is not a replacement for the current Tcl core and Tcllib, which is much improved since Tcl version 4, and other <faster> language constructs. math ops, Tcllib routines, and other compiled routines can reduce the cost of big-data tasks by about 1/3. The time savings of the core are not always obvious on small quantities of data, like 4 or 5 numbers. Performance of one-line programs may suffer degradation due to lengthy recursion calls, and may be limited by constraints on recursion. Dependence on math operator notation, helper procedures, math check examples, degradation due to lengthy recursion calls, and special library functions should be noted in the comment lines.



Letter Scrambler Game in TCL


This modified subroutine, shuffle_with_fixed_first_and_last, takes a list as input and shuffles the inner list while keeping the first and last items in their original positions. The first and last items are extracted and stored in separate variables (first_item and last_item). The inner list is then obtained by removing the first and last items using lrange. The original shuffle subroutine is then called to shuffle the inner list. Finally, the shuffled inner list is concatenated with the first and last items, and the modified list is returned as the result.



Quick Start on Pseudocode


 1.  `shuffle_list_items(list)`:
    -   This function takes a list as input.
    -   Initialize an empty list called `shuffled_list`.
    -   While the input list is not empty:
        -   Generate a random index between 0 and the length of the list.
        -   Add the list item at the random index to `shuffled_list`.
        -   Remove the same item from the input list.
    -   Return the `shuffled_list`.

2. shuffle_list_with_fixed_first_and_last(list):

    -   This function shuffles the inner items of a list while keeping the first and last items fixed.
    -   If the input list has less than 2 items, return the original list (no shuffling needed).
    -   Extract the first and last items from the list.
    -   Create an `inner_list` by excluding the first and last items.
    -   Call the `shuffle_list_items` function on the `inner_list` to get a `shuffled_inner_list`.
    -   Concatenate the first item, `shuffled_inner_list`, and the last item to form the final `shuffled_list`.
    -   Return the `shuffled_list`.

3. Example Usage:

    -   The provided print statements demonstrate how to use the `shuffle_list_with_fixed_first_and_last` function with different input lists:
        -   Shuffling the list `[c, a, t, c, h]`.
        -   Shuffling the list `[t, o, p]`.
        -   Shuffling the list `[b, o, b]`.
        -   Shuffling the list `[t, o]`.
        -   Shuffling the list `[a]`.
        -   Shuffling the list `[s, c, r, a, m, b, l, e, d]`.


References:


  • GoDuck search engine < Functional Programming >
  • GoDuck search engine < Imperative Programming >
  • GoDuck search engine < Programming Examples >
  • Google search engine < vaporware >
  • Tcllib math::special Special mathematical functions
  • Tcllib math::figurate Evaluate figurate numbers
  • Tcllib simulation::random Pseudo-random number generators
  • Tcllib simulation::montecarlo Monte Carlo simulations
  • Wikipedia search engine < Lehmer random number generator >
  • Professor Frisby's Mostly Adequate Guide to Functional Programming on internet archive
  • Writing code using the Pseudocode Programming Process, article by David Zych
  • Mathematical Methods in Large-scale Computing Units
  • by Derrick H. Lehmer
  • L’Ecuyer, Pierre (January 1999). "Tables of linear congruential generators of different sizes and good lattice structure"
  • Mathematics of Computation. 68
  • A Comprehensive Review of Quantum Random Number PDF
  • Good Pedagogical Random Number Generators
  • from J. Stanley Warford
  • Coding the Lehmer Pseudo random Number Generator
  • from W. H. PAYNE
  • The most commonly used version of the Mersenne Twister algorithm
  • is based on the Mersenne prime expr { 2**19937-1 }
  • TWISTER = 431542479738816264805523551633791983905393504322.....
  • GoDuck search engine < TCL version >
  • One Liners Programs Pie in the Sky
  • One Liners
  • One Liners Programs Compendium [L1 ]
  • WIKI BOOKS, Programming_Examples pdf
  • WIKI BOOKS, Tcl_Programming_Introduction pdf
  • Note. I did find a useful online IDE, jdoodle
  • Note. I can paste, edit, and run an output using this online IDE.
  • How Do I Write Pseudocode? video by Mr. Brown CS
  • Refers to rand, RandMT, Mersenne Twister, & random
  • Suchenworth RS on Horseracing in Tcl.
  • Random Number Generators: Good Ones Are Hard to Find, Keith Willam Miller, pdf online
  • Throwing Two Dice GWM and Dice by Keith Vetter.
  • int from RLE has dice expression expr {1 + int(rand()*6)} RLE.
  • Several Dr. Math emails may reduce some dice issues to simple paths, internet archive.
  • Counting Elements in a List from RWT.


Extra Credit on One Line Procedures




  • Wikipedia search engine < random >
  • Wikipedia search engine < dice >
  • Wikipedia search engine < Programming Examples >
  • Google search engine < vaporware >
  • One Liners Programs Pie in the Sky
  • One Liners
  • One Liners Programs Compendium [L3 ]
  • WIKI BOOKS, Programming_Examples pdf
  • WIKI BOOKS, Tcl_Programming_Introduction pdf
  • google search engine < HgA1c to Average Blood Glucose>
  • Tcllib math::numtheory::numberPrimesGauss N
  • math::numtheory::numberPrimesLegendre N
  • math::numtheory::numberPrimesLegendreModified N
  • math::numtheory::differenceNumberPrimesLegendreModified lower upper
  • math::numtheory::listPrimePairs lower upper step
  • math::numtheory::listPrimeProgressions lower upper step





Hidden Comments Section

Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Thanks, gold 12Aug2020