gold

User Page for Gold


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 02JAN2024



Introduction and Greetings

gold Hi, I'm an old Fortran programmer trying to retread. I actually served time on the IBM punch card machines. I collect old Fortran77 books as a hobby. A lot of guys leaving work would give me their old Fortran77 books. On active, i had a large Fortran collection, almost a library. I would loan and check out Fortran77 books to other employees. Also I programmed a lot in Javascript. Mostly I work on TCL now because i am visually oriented and think that a gui can save a lot of time in engineering calculations.



gold6/2/2021. How did you discover TCL/TK ???? >>


gold About 1996, the Personal Computer PC on my desk, was replaced by a Sun Sparc 20 workstation. I was an engineer and mainly programming in Fortran 77. I had learned QuickBasic, Html, Perl (Unix), and also Javascript. Since the Sparc 20 interface was command line Unix, I looked around for a gui or gui language as an interface to the Sparc 20 workstation. I found Tool Control Language TCL fairly easy to mouse click and invoke executable icons on the Xwindows screen. I even had a gimpy trashcan icon on the screen. I showed my beginner TCL program to a co_worker and he said I had fairly imitated the the PC Windows icon system on a Sparc20 workstation. But this was only about 200 lines of beginner TCL code and fast as greased lightning on a Sparc20! How's that for a sales job on TCL? Then, I wrote small slot calculators in TCL and Javascript on the Sparc20 behind a firewall, which were similar to my later pages on this wiki. Never forget the human brain evolved to hunt rabbits, not Unix critters and command lines. Your eyes and brain modeling/mapping of the outside stims are closer to a gui screen than one might think.



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.



Calculator approaches in TCL console guis for Windows10


gold 2021-09-13. These small TCL graphical user interface guis presented in the wiki for Windows10 may seem trivial math to some, but I have submitted 4 or 5 TCLLIB tickets to improve the TCLLIB math library. Many thanks to arjen & Andreas Kupries for the heavy lifting. For example, the math and logic functions IsOdd, IsEven, IsNegative, IsPositive, figurative_numbers, twin_primes, and Quadratic_Equation_Solution_for_reals were not in the TCLLIB library, as near as I can tell. Maybe these logic functions on integers and Quadratic_Equations on reals are trivial math, but these math functions and quadratic equations show up in some other math languages, offsite TCL programs, and even TCL WIKI pages. As discussion with HE implies, the main idea of TCL or other computer language is that other users can share the faster compiled code rather than homebrew functions. I am retired and since I do not have easy access to a UNIX machine anymore, the only course is to proof the TCL routines on a Windows10 PC with ActiveState TCL.


gold Thanks for feedback. These pages is a learning experience (for me). These pade_trig functions in script are very slow and inaccurate past pi/4, compared to the hardware solutions. I will leave the pade_trig procs and Sagemath script (Taylor/Pade/Horner generators) in the alternate listings for the curious reader. If saving computation time, the Sagemath script should be able to convert the odd polynomial into Horner form. I don't see many procs of Pade quotient functions in TCL language on this wiki, so maybe something has been gained.


Npte: Some tickets are closed and functions available in Tcllib. Many thanks to arjen & Andreas Kupries for the heavy lifting.


  • 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
  • ::math::trig::sind angle
  • ::math::trig::cosd angle
  • ::math::trig::tand angle
  • ::math::trig::cosecd angle
  • ::math::trig::secd angle
  • ::math::trig::cotand angle
  • ::math::figurate::sum_4th_power n
  • ::math::figurate::sum_5th_power n
  • ::math::figurate::sum_6th_power n
  • ::math::figurate::sum_7th_power n
  • ::math::figurate::sum_8th_power n
  • ::math::figurate::sum_9th_power n
  • ::math::figurate::sum_10th_power n

  • closed ticket : find interval of Legendre and 2 other estimated primes from two entries (2019-04-24 19:02:32)
  • closed Ticket: find interval of Legendre and 2 other estimated primes from two entries (2019-04-24 19:02:32)
  • puts ::math::numtheory::differenceNumberPrimesLegendreModified 100 0
  • closed ticket : prime factors of integer Created on: 2017-02-03 18:12:23
  • closed ticket : request for the math::number.theory
  • a command for prime factoring of a positive integer would be handy.2017-02-03
  • could include an int if number was floating and return answer for int(n)
  • code from tcl wiki below ordered numbers from low to high, which is good. 2017-02-03
  • (Awaiting Moderator Approval) Add Collatz_sequences And Modified Collatz_sequences To Ticket E035b93f36
  • Closed Ticket, Gauss / Legendre Functions For Number Of Primes In Tcllib
  • Request For Math::number_theory.
  • Would Be Handy To Have 3 Prime Number Functions Like Approx_number_primes = N1 / Ln (N1),
  • Legendre_primes2 = N1 / (Ln (N1)-1),modified_legendre_primes3 = N1 / (Ln (N1)-1.08366).
  • (Awaiting Moderator Approval) New Ticket 5af6381a8b Quadratic Equation Solution, 2 Reals From Muller's Method.
  • New Ticket F8adb7a036 Figurate Numbers And Sums Of Powers.
   ^ open ticket, figurate numbers and sums of powers
  • f8adb7a036 2021-09-18 08:29:50 Patch Open math figurate numbers and sums of powers
  • Closed Ticket: Prime Gap Function And Sets Of Twin Primes,cousin Primes,twin Primes
  • The first proc listPrimePairs returns a list of pairs of primes that differ by a given number and the second proc
  • listPrimeProgressions returns a list of arithmetic progressions of primes that differ by the given number.
  • 0ce5a9fc98 2021-03-14 13:21:47 Patch Closed math ::
  • special prime gap function and sets of twin primes,cousin primes,twin primes
  • df3676c982 2021-03-14 13:31:45 Patch Closed
  • math :: geometry trig angle reduction in degrees or radians
  • 21fef042b9 2021-03-14 13:33:50 Patch Closed
  • math :: geometry add sind ,cosd, etc to geometry functions
  • Closed ticket. As of Jul2018, the TCLLIB has developed code for trig angles in degrees,
  • trig inverse, and hyper functions in degrees, and angle reduction in radians and degrees.
  • ::math::trig::radian_reduced angle
  • ::math::trig::degree_reduced angle
  • ::math::trig::sind angle
  • ::math::trig::cosd angle
  • ::math::trig::tand angle
  • ::math::trig::cosecd angle
  • ::math::trig::secd angle
  • ::math::trig::cotand angle
  • Open 67b7bafb20 math::combined_market_rate 2019-03-02 05:07:49 math::combined_market_rate
  • Open, Gamblers_Ruin_Expectation as Probability in TCLLIB math Created on: 2021-09-19 13:34:34
  • Open, TCLLIB ticket 5af6381a8be0d5a87505d7e28203fe69fa2b3019 in que, dated 7/3/2021
  • Open, Title: Quadratic Equation Solution, 2 reals from Muller's method


  • But I Suppose These Functions Would Be Useful for Proposed Library Collatz_sequences in Tcllib.

Proposed Collatz_sequences And Modified Collatz_sequences Functions In Tcllib.


collatz_sequence_head (27, 4 ) evals  27 82 41 124
collatz_sequence_head (27, 3 ) evals  27 82 41  
collatz_sequence_head (27, 2 ) evals  27 82  
collatz_sequence_head (27, 1 ) evals  27    , initial entry 
collatz_sequence_head (10, 3 ) evals  5 16 8 
collatz_sequence_tail (27, 4 ) evals 8 4 2 1
collatz_sequence_tail (27, 3 ) evals 4 2 1
collatz_sequence_tail (27, 2 ) evals  2 1
collatz_sequence_tail (27 , 1 ) evals   1, final entry
collatz_sequence_tail (10 , 3 ) evals  4 2 1   
collatz_sequence_tail (27, 4 ) evals 8 4 2 1
collatz_sequence_max_sequence_value (27)  evals  9232?
collatz_sequence_max_sequence_value (10)  evals  6
collatz_sequence_length (10)  evals 6
collatz_sequence_length (27)  evals 111?
collatz_sequence_generate  (10) evals  5 16 8 4 2 1 
collatz_sequence_generate  (27) evals 27 82 41 124 62 31 ....


Draft. The Collatz Sequence has several applications and implications in mathematics and computer science:



Gist and Outline on the applications on the Collatz Sequences


The Collatz Sequence, also known as the 3n + 1 problem, is a mathematical sequence that starts with a positive integer n and follows a specific rule: if n is even, divide it by 2; if n is odd, multiply it by 3 and add 1. The sequence continues until it reaches the number 1. The Collatz Sequences serve as a fascinating and versatile mathematical concept with applications in various fields of study. Its simplicity and complexity make it a valuable tool for exploring mathematical patterns and phenomena. The Collatz Sequence has several applications and implications in mathematics and computer science:


1. Mathematical research and Number Theory: The Collatz Conjecture, which states that the sequence will always reach the number 1 regardless of the starting integer, remains an unsolved problem in mathematics. Collatz sequences have been a subject of interest in number theory and combinatorics. Researchers study the behavior of these sequences, trying to determine if they always reach 1 for any given starting number, or if there are any patterns or properties that can be derived from them. Studying the properties of the Collatz Sequence can lead to insights into number theory and the behavior of integers.


2. Algorithm Analysis: Collatz sequences are a popular example of a simple algorithm that can be implemented on a computer to demonstrate the power and limitations of computational methods. The Collatz Sequence is often used as a benchmark for testing algorithms and computational methods. Analyzing the sequence can help researchers understand the efficiency and complexity of different algorithms.


3. Cryptography: The Collatz Sequence has been used in certain cryptographic algorithms and protocols. The unpredictable nature of these Collatz sequences can be exploited to create secure encryption schemes, random number generators, and hash functions. The iterative properties of the Collatz sequence make it a potential candidate for generating random sequences or cryptographic keys.


4. Chaos Theory: The Collatz Sequence exhibits chaotic behavior, with seemingly random fluctuations and patterns. Studying the dynamics of the sequence can provide insights into chaos theory and nonlinear systems.


5. Artificial Intelligence: Collatz sequences can be used in the development of artificial intelligence algorithms. For example, researchers have used them to study the behavior of neural networks and to develop algorithms for solving complex problems.


6. Educational Purposes: The Collatz Sequences are often used as a teaching tool in mathematics and computer science courses. Collatz sequences are a great tool for teaching basic concepts in mathematics and computer science. Collatz sequences can be used to introduce students to algorithms, recursion, and problem-solving techniques. Collatz sequences can help students understand recursion, iteration, and the concept of proof by induction.



Figurate numbers are a type of mathematical sequence


gold 3/8/2024 Update gist. Figurate numbers are a type of mathematical sequence that can be represented geometrically. These numbers can be arranged in the form of regular, geometrical shapes or patterns, hence the term "figurate." Each figurate number corresponds to the number of points that can be arranged to form a specific geometric shape. Some common examples of figurate numbers include triangular numbers, square numbers, pentagonal numbers, hexagonal numbers, and so on. Triangular numbers, for instance, can be represented as equilateral triangles, where each successive number adds an additional row of points to form a larger triangle. Figurate numbers have various applications in mathematics, including number theory, combinatorics, and geometry. They can also be used to solve problems related to patterns, sequences, and geometric arrangements. Overall, figurate numbers provide a visual and intuitive way to understand and explore mathematical concepts.


Projects show up, actions post 1Dec2018


gold 3Dec2018, pages i thought were gone are showing up, largely under Category Numerical Analysis. as s_ noted, i did not use underscores much in early titles. I must learn on to use the goose search engine better. thanks. i have some updates anyway. I will add self_help button. Revamped TCL programs will be listed as V2. The bulk of these files are being stored locally as OpenOffice file.odt files or rich field text files file.rtf, mainly for spellcheck and larger stored fonts for bad eyes. My understanding is that backup on older files are available through the Internet Archive. Like the example of the Wikipedia, i think that an automated PDF dump of the individual TCL/WIKI pages would be a useful storage item, especially if the PDF included a rack of end attachment of the original unix/ascii text data for the unique WIKI table format and the TCL programs. I am scared i will lose formatted tables copy and I have a bunch.


gold 20Mar2020, Message to Middle Eastern Linguist(s) and museum curators on clay tablets. Have made replica clay tokens and published computer programs using the Sumerian math algorithms on clay tablets. Can contribute some to your museum, if interested???? Some ancient and historic algorithms were loaded into the TCLLIB library for the Tool Control Language (TCL).


Revamped Projects under Nikit, actions post 1Dec2018



Projects under old wiki

 >>>>>>  if can't find or link, look older files under category numerical analysis <<<<<<<<
 >>>>>>  for some unk reason, wiki search engine does not push these files to top <<<<<<<<

test below

Babylonian Sexagesimal Notation for Math on Clay Tablets in Console Example
Binomial Probability Slot Calculator Example
Biruni Estimate of Earth Diameter Slot Calculator eample
Chinese Fortune Casting Example Demo
Chinese Sun Stick Accuracy for Console Example
Command Line Calculator in Namespace Package Example
Crater Production Power Law Slot Calculator Example
Drake Intelligent Life Equation Slot Calculator Example
Easy Eye Calculator and eTCL Slot Calculator Demo Example, Numerical Analysis 
Ellipse Properties Slot Calculator Example
Fuel Cost Estimate Log Slot Calculator Example
Generic Calculator Namespace Package Example
Heat Engine Combustion and Calculator Demo Example
Human Language Root Words & Lexicostatistics Calculator and eTCL Slot Calculator Demo Example, numerical analysis
Mahjong_Style_Deletion
Oil Molecule Length Calculator and eTCL Slot Calculator Demo Example, numerical analysis
Oneliner's Pie in the Sky
Paper & Felt Rolls and eTCL Slot Calculator Demo Example
Penny Packing Calculator and eTCL Slot Calculator Demo Example, numerical analysis
Piece wise Profits and eTCL Slot Calculator Demo Example 
Planet Mass Calculator and eTCL Slot Calculator Demo Example, numerical analysis
Poker Probability and Calculator Demo Example
Random Walk Equation Slot Calculator Example
Rectangular Radio Antenna and etcl Slot Calculator Demo Example
Sanskrit Number Words Handling in Formulas and Demo Calculator Example
Sea Island Height Slot Calculator Example
Seaching for Babylonian Triplets Slot Calculator Example
Simple Reliability Slot Calculator Example
Slot_Calculator_Demo
Stonehenge Circle Accuracy Slot Calculator Example
Stratographic Years Slot Calculator Example, Age of Earth
Sumerian Equivalency Values, Ratios, and the Law of Proportions with Demo Example Calculator
Sumerian Beveled Bowl Volume and eTCL Slot Calculator Demo Example 
Sumerian Circular Segment Coefficients and Calculator Demo Example
Sumerian Coefficients at the Bitumen Works and eTCL Slot Calculator Demo Example edit
Sumerian Coefficients at the Weavers Factory and eTCL Slot Calculator Demo Example 
Sumerian Coefficients in the Pottery Factory and Calculator Demo Example
Sumerian Construction Rates and eTCL Slot Calculator Demo Example
Sumerian Paint & Bitumen Coating and eTCL Slot Calculator Demo Example 
Sumerian Population Density and eTCL Slot Calculator Demo Example 
Tonnage of Ancient Sumerian Ships and Slot Calculator Demo Example

Projects to be updated

Sumerian Pottery Vessel Mass Calculator, can not find in new wiki system
Babylonian Square rule for Trapezoid Area and eTCL demo example calculator, numerical analysis
Indian Math Bhaskara (1) Sine formula and extensions, history of math
Kahan compensated summation algorithm and Neumaier variant summation algorithm, numerical analysis
Sumerian Counting Boards, multiplication operation placement strategy, and eTCL demo example, numerical analysis
Babylonian Combined Work Norm Algorithm and eTCL Slot Calculator Demo Example, numerical analysis 
Stonehenge Circle Accuracy Slot Calculator Example
Drake Intelligent Life Equation Slot Calculator Example
Sumerian Equivalency Values, Ratios, and the Law of Proportions with Demo Example Calculator
Piece wise Profits and eTCL Slot Calculator Demo Example
Sumerian Sheep and Herd Animal Calculator and eTCL Slot Calculator Demo Example, numerical analysis
Electronic Failure Rate FITS and eTCL Slot Calculator Demo Example
Sumerian Seeding Rates and eTCL Slot Calculator Demo Example , numerical analysis 
Command Line Calculator in Namespace Package Example
Example Linear Interpolation Calculator
Sumerian Equivalency Values, Ratios, and the Law of Proportions with Demo Example Calculator
Sumerian Beveled Bowl Volume and eTCL Slot Calculator Demo Example 
Population Density Rectangular City Calculator and eTCL Slot Calculator Demo Example
Sales Optimal Lot Order Size and eTCL Slot Calculator Demo Example
Over-21 Game Shell and eTCL Slot Calculator Demo Example , numerical analysis
Sumerian Beer Ingredients and eTCL Slot Calculator Demo Example , numerical analysis
Easy Eye Calculator and eTCL Slot Calculator Demo Example, Numerical Analysis
Paper & Felt Rolls and eTCL Slot Calculator Demo Example
Human Language Root Words & Lexicostatistics Calculator and eTCL Slot Calculator Demo Example, numerical analysis
Sumerian Workday Time & Account Calculator and eTCL Slot Calculator Demo Example, numerical analysis 
Old Babylonian Interest Rates and eTCL demo example calculator
Capsule Surface Area & Volume and eTCL demo example calculator
Babylonian Square rule for Trapezoid Area and eTCL demo example calculator, numerical analysis
Sumerian Coefficients at the Weavers Factory and eTCL Slot Calculator Demo Example
Sumerian Population Density and eTCL Slot Calculator Demo Example

Philosophy On One Liners Programs from One Liners Programs Compendium


I remember when my teenage sister would ask about a math problem. I would lead up and carefully explain this and that algebra proposition. But my sister would say " I just want the answer!" In most engineering problems, there is an advantage in finding the answer in an approximate solution, say slide rule accuracy or 4 significant places. For example, using the old slide rule, one would make a preliminary pencil calculation and approximate answer to set the decimal point, before using the slide rule accuracy to 4 significant places. If one thinks of TCL as primarily as a graphical gui language, then the one liners programs are best used to check the preliminary math concepts. One liners programs and initial console programs are often used to check the math concepts and generate testcases before loading the calculator gui shell.


In planning any software, it is advisable to gather a number of testcases to check the results of the graphical user interface gui program. The results of the testcases are estimated using the hand calculations and then checked in the TCL gui calculator. Pseudocode and equations are developed from the hand calculations and theory. One liners procedures and small console programs are written to check or proof the alternate subroutines or procedures, rather than keeping the unblessed code and comment lines in the main gui calculator. Finally the improved or alternate subroutines are loaded into the gui calculator. The TCL gui or slot calculator is effectively a shell program to input entries, host calculation routines, maintain housekeeping procedures, and display results. Additional significant figures are used to check the TCL calculator, not to infer the accuracy of inputs and product reports.


Reposted Tips from AMG & GWM & Wiki for One Liners Programs


The beginner TCL procedure on the pi circle constant was corrected to proc pi {} {expr acos(-1)} ;# AMG. One Liners Programs should avoid using temporary variables like {set temp 3.14:if {$temp=3.14} {return 1};return $temp}. Temporary variables may cause more time delay, more complication, and possible confusion to reader. The return value of a Tcl procedure is inherited from the return value of the last command to execute within that procedure. Therefore, many uses of the return command are redundant. If one insists on temporary variables, be aware that it is perfectly legal for a proc and a variable to have the same name. You could have said "set pi [pi]". For safety and efficiency, always be sure to brace your expr-essions! Heh, I neglected to brace my expression in [pi], but that's one of the extremely rare cases where it won't matter: no spaces, no substitutions. Bracing does two things: One, when the entire expression is a single word (single argument), it can be bytecode-compiled. Two, if substitutions are performed by expr only and not Tcl itself, injection attacks are prevented. Since the expr command has an internal if conditional, ? in a?b:c sic, try using the internal if <?> in expr rather than a separate IFstatement. Avoid using separate if statements and temporary variables for brevity. The args variable is also useful tool in one liners programs for inputting multiple data or lists of words. Another strategy is to keep track of possible error checks and testcases for low, middle, and high values over the range of operation of the oneliners program. An initial check for zero division or series start at one may be installed in the expr ? conditional. A simple credit for a one liner program may use a semicolon with comment sign <;#> at statement end, which should not degrade program execution. Using the time function in TCL will give even more insights into one liners programs, also see Time. In One liners Programs Pie in the Sky, one can see the advice of GWM on the importance of timing your code and procedures. Usually, invoking math ops, TCLLIB library, and other precompiled libraries can save an average of 1/3 time over big data chores. The time savings are not always obvious on small quantities of data. Performance of one liners programs may suffer degradation due to lengthy recursion calls and limits on the number of procedure recursion calls. The shorter the script, the faster and more reliable is the script. 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. The examples on this wiki page include code lines that might be incompatible, inefficient, or redundant if installed in the same program. As discussed, the local math procedures in scripts and one-line procedures may not be as fast and efficient as importing mathop , mathfunc, and math, so check with the precompiled code in the TCL core and TCLLIB libraries first, then homebrew your one-line programs and scripts.


Flexible Push Button Operation in TCL calculator

gold 10/7/2018. Technical note on TCL calculator buttons addressing the reference ASK12 of 2017-02-19 . Many complex math programs have either initialize, refresh, or reset routines to force correct behavior, using calculator buttons. Of course, a very good feature of TCL is that new variables as number types do not have to be initialized prior to use. Repeating, setting a new number variable to 0 or 1 is not necessary prior to using the variable. I confess that habits brought from prior learned languages and 40 years ago are hard to change. Most of my gui programs on this wiki have a flexible button procedure (on changing labels and resetting variables prior to calculations). Where the program defaults are recalled, canvas colors/features/variables/clear displays are reset prior to ( in push button list) calculation. The buttons on the calculator are not limited to a single action proc or single shot. A button command may call multiple statements and procs like ::ttk::button .test4 -text "Test_wild_case3" -command {clearx; refresh_canvas_x .cv; fillup 120. 12.0 15.0 1. 1. 1. 1. 104.0; set global_variable 9999.;solve_routine;printout_routine;# need semicolons here; exit}. This is effectively a separate program or subprogram installed as list of procedures in a button.


The TCL language is very flexible, and as experiments, the button may invoke a do while routine to call the listed button procs multiple times like the infinite repeater (SiFi). The button may invoke command and call procedures for a random number of times and random solutions, like nerve and muscle firings from the human brain in thought and speech (not SiFi). For cosmetics, the button may set colors, frame width, canvas objects, and variables with the random proc lpick from RS on the wiki. As long as duplicate frames, duplicate canvas, pack managers, and channels are not confused reference the original program, one can load secondary and entire procs into the button list. Returning to the conventional use of resetting variables, the button refresh and initialize tactic should work across the TCL versions, at least in the versions tested (TCL8.5, and TCL8.6).


Most of the testcases involve experiments or models, using assumptions, and rules of thumb. For the push buttons in the TCL calculator, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console to conventional texteditor. For testcases in a computer session, the TCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers should be cleared either on the clear button or on the next solve button.



2021 Newsflash, TCLLIB has twin primes and cousin primes routines in TCLLIB:math ticket pipeline


gold 5/13/2021.


closer: arjenmarkus AM


Emailed icomment from AM: I used the sample code to create two new procedures:

  listPrimePairs 
  listPrimeProgressions

The first proc listPrimePairs returns a list of pairs of primes that differ by a given number and the second proc listPrimeProgressions returns a list of arithmetic progressions of primes that differ by the given number.


Posted Questions on Ask13


Is tcllib library in Sep2021 ActiveTCL most recent copy??


This item is being surfaced with friendly and quality support at ActiveState.com


gold9/22/2021 I recently installed ActiveState TCL or ActiveTCL on Windows10. I have been working with ticket additions to tcllib math files. Maybe I am wrong, but the ActiveState installer from the ActiveState website (9/22/2021} installs the old Tcllilb content (Tcllib (tcllib-1.18) of three years ago in 2019. I tried installing the current library content from the https://sourceforge.net/projects/tcllib/ plus https://www.tcl-lang.org/software/tcllib/ . It looks like the new content Tcllib tcllib-1.20 is present now, on my local ActiveTCL copy. This installation is very tricky for a 70+ year old novice with bad eyes. And I am not sure that I installed tcllib-1.20 right. Thank You


gold9/22/2022. PS. I double checked this morning and fresh reloaded the ActiveTCL on 9/22/2021 The old library (Tcllib (tcllib-1.18) is still there in a fresh download of ActiveTCL.


  • PS. References. 9/24/2021 I noted the new content tcllib-1.20::math in Tcllib distribution has modules. My local ActiveTCL seems to be pulling the Tcllib:math routines, that I normally use. But my local ActiveTCL copy and setup is not a shakedown cruise on the whole Tcllib deck and TCL core, which is very large with noted modules. Refer to TIP 189: Tcl Modules, Tcl Modules, [L13 ]

Suggest Category on Windows_Examples


gold 9/19/2021. Would a wiki category on Windows_Examples_PC or Windows_Console be worthwhile? As separate from Windows Operating system? I really like some opinions. I worked 15 years on Sun Sparcs Unix, so familiar with UNIX, but am a retired engineer now. Curious about the percentage of Unix users vs PC users vs Apple on TCL wiki. Thank You. [L14 ]& [L15 ] & [L16 ]



Solved and Closed out, old edit copy on screen.


gold 9/12/2021


When I come in as unsigned-in , the very first edit on Sep11 comes up on screen. Collatz_Sequences (3*N+1) in Console Example Demo for TCL V2. HE and I have made a bunch of changes to file. Is there some way to update page to latest edit copy, 43 or so. Thank you.


gold 9/27/2021. Closed out. I found out the trick by myself. If one picks Save button, copy goes into holding pattern or possibly quality control. If one picks Save as Minor as Minor Edit Button, the ones current edited copy is updated and appears in current in the current files.


Collatz_Sequences_new_page


Screen on 9/14/2021, Collatz_Sequences_not_updated_since_9_11, see date tag on bottom


Collatz_Sequences_not_updated_since_9_11


Solved on 7/01/2021. Quadratic equations using TCLLIB

gold 6/29/2021. I am working on wiki page {https://wiki.tcl-lang.org/page/Seaching+for+Babylonian+Triplets+Slot+Calculator+Example ]. Can someone point me to a quadratic solution command or proc in TCLLIB? or TCL core. Understand, I have access to Quadratic solution procs in TCL or could write one. But I am looking at the files in TCLLIB math and don't recognize the quadratic solution proc section. Thank you.


AM There is none, if you mean to solve a second-degree equation. The references to "quadratic" in the math module are all for very different entities.


gold 7/2/2012. I'll write a small proc to solve quadratic equations and put a ticket in the TCLLIB que. There was an interesting note on the quadratic equation in [L17 ] & [L18 ] Thank you.


TCLLIB ticket 5af6381a8be0d5a87505d7e28203fe69fa2b3019 in que, dated 7/3/2021
Title:        Quadratic Equation Solution, 2 reals from Muller's method

Reference [L19 ]


Possible Uses of Collatz Sequences Conjecture


Offsite query from Senior TCL Enginner. 9/22/2021 was "What are the possible computer application uses of the Collatz Sequences Conjecture?


As understood here, the Collatz Sequences Conjecture is called pure mathematics. Paul Erdos said about the Collatz conjecture: “Mathematics may not be ready for such problems.” The Collatz Sequences Conjecture is at the forefront of human mathematics. The topic of the Collatz Conjecture was rated "High Priority" by WikiProject Mathematics circa Sep2021, a collective measure of Mathematicians priorities and popularity to be sure. From what an outsider can tell, the Collatz Sequences are being generated with supercomputers and distributed computing algorithms on the numeric issues. Apparently, the Collatz Sequences are as valid a test for computing machines, parallel algorithms, and distributed computing algorithms as the 1) search for pi, 2) search for highest prime number, 3) Twin Prime Conjecture, and 4) factoring numbers. In 2020, starting values up to 2**268 approximating 2.95*1020 have been checked in the Collatz conjecture. In 2019, a paper proposed using Collatz Sequences for signal encryption, High-uncertainty audio signal encryption based on the Collatz conjecture. Other papers have mentioned the buzzwords "quantum mechanics computing" and fuzzily implied that the Collatz conjecture may be analogous to setting quantum levels in a quantum device. I am a retired engineer. I have put some queries out to the pure mathematicians.


Alan Turing created the concept of a “universal computing machine” about 1937. The seminal 1937 paper was titled: On Computable Numbers With an Application to the Entscheidungsproblem. A Turing machine is a theoretical abstraction of a computing engine, but usually is presented and resolved to a computer program on existing physical computers today. There have been a number of papers laying out concepts for Turing machines based on the Collatz Sequences Conjecture. These Turing machine concepts usually use the Collatz Sequence calculations and procedures <+,/,*> in a decision matrix and rate how the conceptual Turing machine smoothly solves for Collatz Sequences in a continuous computation loop without halts and flaws. I might point out that the original Collatz Conjecture procedures involving simple <+,/,*> operations here have been spun out into Collatz-like problems, different formula approaches, and radical looking reformulations.


ProvisionaI text. I still have some queries out to pure mathematician associations and institions Collatz Sequences uses. If they answer back, the pure mathematicians may come back with different and more authoritive uses of Collatz Sequences than the retiree brigade. link to https://wiki.tcl-lang.org/page/Collatz_Sequences+%283%2AN%2B1%29+in+Console+Example+Demo+for+TCL+V3+?V=158 .


---

Insights into the Collatz Infinite Sequences


Clipping off the repeating terminus of the known Collatz Sequences means the sequence is still fundamentally an infinite sequence. However, the mathematicians have changed some of the original formula to make the Collatz sequence close faster. The modified Collatz sequence does close faster and has a smaller envelope with the term (3*N+1)/2. As an analogy, this is similar to the converging and diverging of a series. The original Collatz sequence is a divergent sequence in that sense, because the Collatz sequence never closes to an exact numerical limit. Briefly, similar terms to Collatz sequences are possible as generic ($C1 * N + $C2)/2. Another breakdown in similar terms to Collatz sequences is (N+2*N+1)/2. The advantage of (4*N-1*N+1)/2 is that a fourth math operation {+-*/} is added to in the original setup {+*/}. Since I have worked more with converging series on this wiki etc, I would be interested in turning the Collatz sequences into a converging series. Possibly a Collatz sequence morfed into successive ratios like the successive Fibonacci series produce the Golden Ratio (1.618) . From the previous examples, the collatz_sequence of 5 is < 5 16 8 4 2 1 >. Converts to < 8/16 4/8 2/4 1/2 > and sum from expr { 8/16. + 4/8.+ 2/4.+ 1/2. } , 2. Possibly, sum is number of terms times half?, $ND*(1./2).


Possible Uses of Collatz Sequences Conjecture


Offsite query from Senior TCL Enginner. 9/22/2021 was "What are the possible computer application uses of the Collatz Sequences Conjecture?


As understood here, the Collatz Sequences Conjecture is called pure mathematics. Paul Erdos said about the Collatz conjecture: “Mathematics may not be ready for such problems.” The Collatz Sequences Conjecture is at the forefront of human mathematics. The topic of the Collatz Conjecture was rated "High Priority" by WikiProject Mathematics circa Sep2021, a collective measure of Mathematicians priorities and popularity to be sure. From what an outsider can tell, the Collatz Sequences are being generated with supercomputers and distributed computing algorithms on the numeric issues. Apparently, the Collatz Sequences are as valid a test for computing machines, parallel algorithms, and distributed computing algorithms as the 1) search for pi, 2) search for highest prime number, 3) Twin Prime Conjecture, and 4) factoring numbers. In 2020, starting values up to 2**268 approximating 2.95*1020 have been checked in the Collatz conjecture. In 2019, a paper proposed using Collatz Sequences for signal encryption, High-uncertainty audio signal encryption based on the Collatz conjecture. Other papers have mentioned the buzzwords "quantum mechanics computing" and fuzzily implied that the Collatz conjecture may be analogous to setting quantum levels in a quantum device. I am a retired engineer. I have put some queries out to the pure mathematicians.


Alan Turing created the concept of a “universal computing machine” about 1937. The seminal 1937 paper was titled: On Computable Numbers With an Application to the Entscheidungsproblem. A Turing machine is a theoretical abstraction of a computing engine, but usually is presented and resolved to a computer program on existing physical computers today. There have been a number of papers laying out concepts for Turing machines based on the Collatz Sequences Conjecture. These Turing machine concepts usually use the Collatz Sequence calculations and procedures <+,/,*> in a decision matrix and rate how the conceptual Turing machine smoothly solves for Collatz Sequences in a continuous computation loop without halts and flaws. I might point out that the original Collatz Conjecture procedures involving simple <+,/,*> operations here have been spun out into Collatz-like problems, different formula approaches, and radical looking reformulations.


gold 9/24/2021. Provisional text. I still have some queries out to pure mathematician associations and institutions on Collatz Sequences uses. If they answer queries, the pure mathematicians may come back with different and more authoritative uses of Collatz Sequences than the retiree brigade.



Conclusions


gold Many thanks to HE for comments and feedback. In terms of use on other TCL platforms, I am interested in proving and petitioning the collatz_sequence code to the TCLLIB. On my own PC on Windows 10, mostly I attach a proven subroutine to the command line interface and type into the TCL Windows10 console, meaning Easy Eye [L20 ]. At present, all i do is tap once on the icon (text linked to ActiceTCL) of the Easy Eye console and I am up and running. I am not sure how one could test a numeric program without some listing of canned test cases, printout, or other wiki style printout? I might point that to test compatibility with TCLLIB, I do test homebrew code loaded in the local copy of TCLLIB math and associated libraries.This is a local setup on Windows10, so references to a my local TCLLIB::math library would not be portable.


gold 2021-09-13. "And slowly, I turn inch by inch" - Movies. I have swapped ;# for # in comment lines. I have seen punctuation ;# semicolon hash and set list_values { 1 2 3 4 } before as a list creation, meaning from some professional coders on the internet. But I will defer to your judgement here. In 2020, starting values up to 2**268 approximating 2.95*1020 have been checked in the Collatz conjecture. Yes, one would need math::bignum and math::bigfloat package for that and to check all speed savings on supporting integer procs for Collatz sequences at that size. Recognize that collatz_sequence are considered integer sequences, but Gauss and Legendre used exponential and logs on real numbers to predict the Prime integer number density on the numberline. Terence Tao has published some auxiliary formulas for probability quantities etc from his Collatz_Sequences developments, which might be treated as large real precision numbers in TCL. Although Terence Tao does not use the TCL terms of real decimal numbers, as one might expect from the "pure" mathematician. I am loading my exponential cannon with real numbers and TCL gunpowder, set tclprecision 17. Refer to Gauss Approximate Number of Primes and eTCL demo example calculator. According to Richard Suchenwirth on TCL wiki, and quoting directly " Since the console is a TK text widget, you can use all text widget commands and options on it." Refer to [L21 ] The grid Tk widget, grid Tk widget, and Tk::button all support the panel display of the Windows10 gui here. I am still learning TCL/TK. And I can not rule out that dropping the statement "package require Tk" in the Windows10 decks might have unforeseen consequences, to include other user Windows10 machines if not my own Windows10 setup. The title of wiki page and original TCL program included words '"Console Example" and "written on Winidows10". I think that the TCL WIKI is big enough to support both UNIX and Windows10 in separate groups, modus vivendi. However, your good comments have catalyzed me. I will start looking for a graphical user interface gui or template code that is cross platform, equally accessible to UNIX and Windows10. Aside from Windows10, and TCL, I wrote about 20 years of calculator guis on Javascript and UNIX at work. The main task for me was getting the ticket on Collatz_Sequences out the door.


gold 2021-09-21. I have the TCL gui graphical user interface for Collatz_Sequences working on Windows10 Console TK widget in under 288 lines of code. Meaning, one tap on the icon of the ActiveState TCL Console gets one up and running on Windows10. The gui dependency on the ActiveState TCL and Windows10 Console Tk widget has been noted sufficiently on the page title and source code. Respectfully, I remind one that I have been out of the classroom for 50+ years, and Fortran77 classes at that. I hope I may be forgiven for a few UNIX faux pas in a Window10 Console program. I welcome others on the Wiki to proof, improve, or proof the code on UNIX machines on any independent UNIX pages. I believe that the proposed implementation of the Collatz_Sequences functions in the Tcllib will accommodate the UNIX users of TCL. Sep2021 PM quote, "ActiveTcl users are overwhelmingly on Windows (80% or so), and tend to have a high proportion of novice to intermediate users." One may infer that the UNIX users of ActiveState TCL are a very intelligent, more experienced Linux users, and very sophisticated set of TCL users, if not driving the pack. I do not have all the answers. Maybe, as one infers, the ActiveState TCL Windows10 Console and TK widgets are not the best path?


gold 2021-09-13. Solved problem. The proc collatz_sequence was substantially rewritten by HE and I replaced in the main deck and good feedback comments, which I will have to chew on. Many thanks to HE. I checked the proc collatz_sequence in small test suite and proc looks good, so I will pass ticket on to TCLLIB math. I have loaded the ticket e035b93f36 Title: Collatz_Sequence, modified_Collatz_Sequence, positive & negative logic test for integers.


gold 2021-09-13. These calculator approaches in TCL console guis for Windows10 may seem trivial math to some, but I have submitted 4 or 5 TCLLIB tickets to improve the TCLLIB math library. For example, the math and logic functions IsOdd, IsEven, IsNegative, IsPositive, figurative_numbers, and Quadratic_Equation_Solution_for_reals were not in the TCLLIB library, as near as I can tell. Maybe these logic functions on integers and Quadratic_Equations_Solutions on reals are trivial math to some, but these Quadratic_Equations_Solutions and other math functions show up in some other math languages, TCL programs, and even TCL WIKI pages. As HE implies, the main idea of TCL or other computer language is that other users can share the faster compiled code rather than homebrew functions. Since I am retired and I do not have easy access to a UNIX machine, the only course in the retirement economy is to proof the TCL routines on a Windows10 PC.



Use of Global Variables in TCL GUIS


gold 12Dec2018. Global variables, regular expressions, and namespaces are considered advanced features of the Tool Control Language (TCL), according to Brent Welch in Practical Programming in TCL and TK. If global variables are an advanced feature of TCL, as indexed and taught after the beginner TCL topics in most TCL textbooks, then reasonably the use of global variables should be explored and discussed on the wiki. After a number of searches on the wiki and reference books, the topics of regular expressions and namespaces are adequately explored on the wiki and available textbooks. In opinion, the use of global variables in TCL programs should not be restricted to a narrow viewpoint, and the use of global variables could be a very rich vein of interest for the advanced student of programming. As an engineer with 35 years experience in Fortran, Basic, Javascript, and other computer languages, the author is familiar with self-appointed gatekeepers and the other anonymous ad hominem methods of NDH. NDH means “not done here”, “not done here in our shop”, or “not done here in my programming style”. Global variables in TCL are equivalent to the common variable statements in Fortran and Basic. The use of global variables might be called “sideloading" for data subroutines. Ref Fortran77, the large number crunching programs with 2E5+ statements in Fortran used global variables or common variable declarations as an alternate way or “programming style” to transfer or sideload information between subroutines. The other data transfer method for subroutines was discussed by Brent Welch etc in the proc command arguments or top loading in the introductory or beginner TCL material.


gold 12Dec2018. Of course, each alternate way of data information transfer in toploading and sideloading data subroutines has its own advantages and disadvantages. As most TCL users know, TCL tends to be a more compact language than Fortran77. However, the global declarations in the small TCL graphical user interface guis written for numerical analysis on this wiki have exactly the same common variable structure and same program organization as the giant Fortran number crunchers.


gold 12Dec2018. There are two alternate methods of loading TCL subroutines, known as proc arguments (top loading) and global variables (side loading). In engineering terms, the TCL global variable methods and the Fortran common variables are an economy of scale for large programs. In other words, top loading a data subroutine for a small program with a limited number of variables and a limited number of subroutines is about as efficient as global variables (side loading). When a large program has the number of variables approaching 25 variables and the total number of subroutines approach 20 subroutines, then global variables or common variables become an more attractive alternative data transfer between subroutines and a more efficient use of the programmer's time. This principle is independent of language type, and equally true for the TCL, Fortran, and other computer languages. For example, many scientific Fortran programs had a specialized subroutine for constants, including the gravity constant, speed of light, etc. If the gravity constant was used in 15 subroutines, it was easier to declare the gravity constant as a common variable in a constants subroutine, and then make a one time change in the value of gravity constant in one subroutine of constants than making the same change for the gravity constant in 15 subroutines. If one knows than the sequence of slot variables {$side1,$side2,$side3...$side8...$side_N} and other constants are TCL global variables throughout the subroutines, one can easily refer to these global values in a specialized printout report subroutine. One can also load these global values in formulas for printout and separate calculations on the fly. For a side loading example in a new subroutine, proc newby {} {global side1 side2 side3; puts <* $side1 $side2 $side3>;return <+ $side1 $side2 $side3>}. The alternative top loading would be proc newby {side1 side2 side3} { puts <* $side1 $side2 $side3>;return <+ $side1 $side2 $side3>}. Both subroutine methods work for small TCL programs with the roughly same amount of typing. Remember in top loading, one would have to make other changes in the invoking statement or proc argument statement for the subroutine. One might point out that loading more than 25 variables in either an invoking statement or proc statement is not a trivial exercise to kept correct and cued properly. For another example, a specialized subroutine for printing out variables might use s set of global variables as proc printout {} { global side1 side2 side3; puts $side1; puts $side2; pouts <* side1 side2 side3>; puts "conversion to centimeters"; puts <* $side1_inches 2.54 >; }. A specialized printout subroutine with globals previously declared is faster in development and checking numeric formulas in experience, especially where conversion of units like inches and centimeters is useful for checking the results of the program in older textbook problems.


In opinion, a set of the same global statements in numerous routines are easier to keep organized. The condition of using global variables in method is that the user understands that not all variables are invoked over all the numerous subroutines. Therefore, in the case of multiple variables > 25 and multiple subroutines >20 in a large program, changing a constant variable in a large number of subroutines, little to do in the proc argument statements and invoking the subroutines, and the availability of the global variables throughout the program means less time spent on changes for the programmer. For terms of TCL presentation on the wiki, the slot variables could be changed inside the subroutine to recognizable names in variables for the calculations and quicker comprehension of the reader. In opinion, global variables are a more efficient use of the programmers time for a quick assembly of a working gui or installing a new working subroutine in a large TCL program.


gold 12Dec2018. The author is still learning TCL. These small TCL graphical user interface guis presented in the wiki have gone through an evolution of about twenty years, including numerous unpublished Javascript and TCL guis behind a firewall before joining the wiki. The suggestions from the wiki members have been of great help and these TCL guis have continued to improve. The guis are experimental numerical analysis in nature, and not every early TCL gui or program written over the twenty year period has the same global variable features, structured programming, or beauty spots of the TCL gui genre. The author keeps hearing that TCL is not a number crunching language or an outdated language from non-users. But in the instance of the TCL global variables, the TCL globals have the equivalence of the common statements and common variables in the data subroutines of giant Fortran number crunchers.



Maybe partially solved, trouble accessing the TCL WIKI from USA on some restaurant WIFI's?

gold 7/16/2020, Report so far, in coordination with ActiveState Support [email protected]


gold 08Jul2020. Don't know if other members of TCL Club have this problem, but the author is having great difficulty in accessing this TCL WIKI, since the TCL WIKI and other download TCL programming sites on public WIFI are blocked in the USA. Accordingly, the USA based search engines are apparently not accessing the TCL programming sites. Frantically, the blocked TCL sites will affect the availability,promulgation, and succe$$ of the TCL language. Believe that the TCL language has much to offer mankind, if the TCL language and its amazing utility are not blocked to mankind by gatekeepers, iconoclasts, and bookburners in the USA.


many thanks for help. I am still locked out from easy access to TCL Wiki. but i will report your efforts to the TCL WIKI. Is there an address to resolve issues with ATT ? . I tried to contact ATT, but there is merry-gr on that website. thanks again,gold

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, August 13, 2020 2:50 PM, ActiveState Support <[email protected]> wrote:

Hi Gold

I'm not sure if you've been able to work around this or have it fixed yet. I can still see "Error 1000" issues on Cloudflare though with the aliased tcl.activestate.com. Maybe that domain change is being detected as a cross-site redirection attempt and blocked for that.

I'm not clear why, but there is a difference between how wiki.tcl-lang.org and tcl.tk resolve. Maybe that was intended to work like a backup site, or maybe something is out of sync:

:~$ host tcl.activestate.com tcl.activestate.com is an alias for wiki.tcl-lang.org. wiki.tcl-lang.org has address 104.18.184.65 wiki.tcl-lang.org has address 104.18.183.65 wiki.tcl-lang.org has IPv6 address 2606:4700::6812:b841 wiki.tcl-lang.org has IPv6 address 2606:4700::6812:b741 :~$ host wiki.tcl-lang.org wiki.tcl-lang.org has address 104.18.183.65 wiki.tcl-lang.org has address 104.18.184.65 wiki.tcl-lang.org has IPv6 address 2606:4700::6812:b741 wiki.tcl-lang.org has IPv6 address 2606:4700::6812:b841

:~$ host www.tcl.tk www.tcl.tk has address 104.16.56.90 www.tcl.tk has address 104.16.33.94 www.tcl.tk has IPv6 address 2606:4700::6810:385a www.tcl.tk has IPv6 address 2606:4700::6810:215e

whois 104.16.56.90 and whois 104.16.33.94host reports that's Cloudflare. whois 104.18.183.65 and whois 104.18.184.65 also reports Cloudflare

Best regards,

Technical Support Engineer ActiveState Software


APN What URL are you using to access? The tcl.tk domain is problematic (from the blocking perspective), the official name is now wiki.tcl-lang.org. Do you have problems with that domain as well?

gold 7/11/2020. Thanks for feedback. Possibly problem is default security setting on browser or virus firewall security going into a WIFI proxy server. Realize the TCL CLUB is not a 9 to 5, but this item is really cutting down my production and access to TCL references. But the browsers are changing into complexity, pretty fast for a retiree. Quotes """ If you don't believe you should be using a proxy server: Go to the Dissenter menu > Settings > Show advanced settings… > Change proxy settings… > LAN Settings and deselect the "Use a proxy server for your LAN" checkbox. UNQuote"""" The strange thing is that I can see https://wiki.tcl-lang.org/welcome and https://sourceforge.net/projects/tcllib/ at Starbucks coffee and some "bar" WIFI's, but I can not see the TCL Wiki same at Mcdonalds, Wendy's, and some other quick stop WIFI's.


7/13/2020. trouble coming from Macdonald restaurant etc ATT WIFI?? https://login-mcd-cluster.prd.....snantx.attwifi.com/g error messege found after site log. SIC http://tcl.activestate.com/software/tcllib/tcl.activestate.com’s server IP address could not be found. Try:


Checking the connection Checking the proxy, firewall, and DNS configuration Running Windows Network Diagnostics ERR_NAME_NOT_RESOLVED




http://wfr.tcl-lang.org/ https://login.attwifi.com/blocked/blocked_page.html#?......&web_rep=%3Ctrustworthy-sites%3E&web_cat=%3Cshareware-and-freeware%3E


Hi,

7/16/2020. ActiveState hasn't hosted the Tcler's Wiki for a while. From what I see in that error message though, it looks like the ATT network has DNS entries that still point to tcl.activestate.com, whereas the other providers are using the official URL instead.

We might have had a redirect sending tcl.activestate.com to the new official URL, and that redirect might have gone out of service. I have asked our IT team to investigate.

Best regards,

GS. ActiveState Software

NEW! ActiveState Platform: Build - Certify - Resolve Login to get your ActivePerl/Python/Tcl builds: https://platform.activestate.com/ .

gold 7/16/2020, end of file


                # pseudocode on Babylonian triplets
                2m, m**2 - 1, m**2 + 1  Babylonian triplet
                twin prime number.
                twin prime numbers separated by 2,4,6 ...?
                c**2= a**2 + b**2
                c**2= a**2 + 1        normalized Babylonian triplet
                a**2  = c**2 -1       normalized Babylonian triplet
                some b and c are both primes.
                some b and c are not both primes.
                The reciprocal pair relationship.
                (X+1/X)**2 - (X+1/X)**2 = 4  ,    divide equation by 4 
                normalized triplet, < (1/4)* ((X+1/X)**2 ) , 1 ,(1/4)* ((X+1/X)**2) >
                0 < X-1/X < 2
                1< X-1/X < 1+sqrt(2)     ~~ approximate limit of 2.4 
                The Babylonian regular numbers between 0 and 60 have a limited set of triplets that
                satisfy 1< X-1/X < 1+sqrt(2) which appears to be the role of Plimpton 322.
                The limit 1< X-1/X < 1+sqrt(2) may explain the 1<X<2 limit on the Late  Babylonian
                many place reciprocal tablets.
                d=6 even number, l = divisor of d**2 with integer result, Babylonian triplet method
                a=l+b
                b= d+ (d**2)//(2*l)
                c= d+l+(d**2)/(2*l)
                # supposed to work for all even d

Possible Bias of base 2 and 3 in near field?

New report indicates that binary numbers and base 3 may a bit biased in the near field. But don't think the sample is large enough in this trial program.

                # Pretty print version from autoindent
                # and ased editor
                # Possible Bias of base 2 and 3 in near field?
                # written on Windows 10 on TCL
                # working under TCL version 8.6
                #   on TCL Club , 18aug2020
                # relative frequency of indiv. "throw" over all "throws".
                # pi mantissa used here
                # proc base and frombase by RS
                package require Tk
                console show
                # proc base by RS
                proc base {base number} {
                    set negative [regexp ^-(.+) $number -> number] ;# (1)
                    set digits {0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N
                        O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p
                        q r s t u v w x y z}
                    set res {}
                    while {$number} {
                        set digit [expr {$number % $base}]
                        set res [lindex $digits $digit]$res
                        set number [expr {$number / $base}]
                    }
                    if $negative {set res -$res}
                    set res
                }
                  # proc base by RS
                proc frombase {base number} {
                    set digits {0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N
                        O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p
                        q r s t u v w x y z}
                    set negative [regexp ^-(.+) $number -> number]
                    set res 0
                    foreach digit [split $number ""] {
                        set decimalvalue [lsearch $digits $digit]
                        if {$decimalvalue<0 || $decimalvalue >= $base} {
                            error "bad digit $decimalvalue for base $base"
                        }
                        set res [expr {$res*$base + $decimalvalue}]
                    }
                    if $negative {set res -$res}
                    set res
                }
                proc calculation {  facen }  {
                    # prob. subroutines for mimic sequence of bronze
                    # prob. is throw combos of eg. "7" over all possible throws
                    # set lister [split {14159265358979323846} ""] 
                    # in base 3        10111100001122100002122202221020002210001 
                    # in base 2  1100010001111111110100001101001100110010011101001101011111000110 
                    set target [ base 3 14159265358979323846 ]
                    set lister [split { 1100010001111111110100001101001100110010011101001101011111000110  } ""]                   
                    set ee [llength  $lister ]
                    set kk [ llength [ lsearch -all $lister $facen ] ]
                    set prob [ expr { ($kk*1.) / $ee  } ]
                    return $prob
                }
                set limit 12
                puts "%|table| printed in|TCL format |% "
                puts "&| quantity| value| comment, if any|& "
                for { set i 0 } { $i <= $limit }  { incr i } {
                    lappend listxxx $i
                    lappend listxxx [ calculation  $i ]
                    puts " &| $i | [ calculation  $i ] |  |&"
                }
                #end
               puts " [ base 2 14159265358979323846 ] "

table printed inTCL format
quantity value comment, if any
0 0.4461538461538462
1 0.5384615384615384
2 0.0
12 0.0 1100010001111111110100001101001100110010011101001101011111000110

binary pi in 512 places. 11. 0010010000111111011010101000100010000101101000110000100011010011 0001001100011001100010100010111000000011011100000111001101000100 1010010000001001001110000010001000101001100111110011000111010000 0000100000101110111110101001100011101100010011100110110010001001 0100010100101000001000011110011000111000110100000001001101110111 1011111001010100011001101100111100110100111010010000110001101100 1100000010101100001010011011011111001001011111000101000011011101 0011111110000100110101011011010110110101010001110000100100010111


table printed inTCL format
quantity value comment, if any
0 0.5394990366088632 binary pi in 510 digits
1 0.44701348747591524
2 0.0

  • Unexpected biases in the distribution of consecutive primes
  • Robert J. Lemke Oliver, Kannan Soundararajan ,Department of Mathematics, Stanford University
  • The Last Digit of Prime Numbers - Numberphile on Youtube
  • Lecture on “Rock, paper, scissors in probability, Tadashi Tokieda
  • Hardy-Littlewood conjectures.
  • MATHEMATICS SCIENCE, A new pattern in primes, Shubashree Desikan, Hindu Times
  • en.wikipedia.org wiki search on Tadashi_Tokieda
  • https://www.ncbi.nlm.nih.gov articles/PMC4978288/
  • Distribution of the units digit of primes, C. M. Ko, National Central University
  • www.wired.com tadashi-tokieda-finds-startling-objects-in-plain-sight/

Subroutine Template

        # adapted from tcl-wiki Stats 2011-05-22, arithmetic mean  [RLE]
        #
        # ::math::quantity_into_ratios --
        #
        # Return the division of quantity by  two or more given ratios
        #
        # Arguments:
        #    val  first value is quantity
        #    args other values are two or more given ratios
        #
        # Results: parts of quantity divided  by ratios
        #
        proc ::math::quantity_into_ratios {quantity args} {
            set sum 0.
            set N [ expr { [ llength $args ] + 1 } ]
            if { $N == 1  } { return 0 }
            foreach val $args {
                set sum [ expr { $sum + $val } ]
            }
            foreach val $args {
                lappend answer [ expr { $quantity * ($val/$sum) } ]
            }
            set answer
        }
        #puts "  ::math::quantity_into_ratios ( 84 2 2 2  )  answer 12.0 24.0 48.0    "
        #puts " [ ::math::quantity_into_ratios 84 1 2 4  ]  "
        #puts " [ ::math::quantity_into_ratios 84 ] for (::math::quantity_into_ratios 84) returns zero "

sqrt_sum_of_squares


        # adapted from tcl-wiki Stats 2011-05-22, arithmetic mean  [RLE]
        #
        #  sqrt_sum_of_squares --
        #
        # Return the sqrt_sum_of_squares by  one or more
        #
        # Arguments:
        #
        #    args other values are one or more
        #
        # Results: sqrt_sum_of_squares
        #
        proc sqrt_sum_of_squares { args} {
            set sum 0.
            set N [ expr { [ llength $args ] + 1 } ]
            if { $N == 1  } { return 0 }
            foreach val $args {
                set sum [ expr { $sum + $val*$val } ]
            }
            set answer [ expr { sqrt($sum) } ]
        }
        #puts "  ::math::sqrt_sum_of_squares (  2 2 2  )  answer [sqrt 12 ]
        #  3.4641016151377544
        #puts " [ ::math::sqrt_sum_of_squares   1 2 4  ]  "
        #puts " [ ::math::sqrt_sum_of_squares 2 ] for ( ) returns zero "
        console show
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        puts "  sqrt_sum_of_squares  2 2 2 equals [ sqrt_sum_of_squares  2 2 2 ]"
        puts "  sqrt_sum_of_squares  1 1 1 equals [ sqrt_sum_of_squares  1 1 1 ]"
        puts "  sqrt_sum_of_squares  1 1  equals [ sqrt_sum_of_squares  1 1  ]"
        puts "  sqrt_sum_of_squares  1  equals [ sqrt_sum_of_squares  1  ]"
        puts "  sqrt_sum_of_squares  0  equals [ sqrt_sum_of_squares  0  ]"

output for sqrt_sum_of_squares


  sqrt_sum_of_squares  2 2 2 equals 3.4641016151377544
  sqrt_sum_of_squares  1 1 1 equals 1.7320508075688772
  sqrt_sum_of_squares  1 1  equals 1.4142135623730951
  sqrt_sum_of_squares  1  equals 1.0
  sqrt_sum_of_squares  0  equals 0.0

Modify discrete events on tugboats_tester3


From Discrete event modelling with coroutines by Author : Arjen Markus (21 april 2009). Added easy eye console for my bad eyes.


        # coro_discrete_events.tcl --
        #     Experiment with SIMULA/DEMOS like modelling - using coroutines
        # from Discrete event modelling with coroutines
        # Author : Arjen Markus (21 april 2009) 
        # Discrete event modelling is a way of modelling all manner of systems
        package require Tcl 8.6
        # acquire --
        #     Acquire resources and wait if that does not succeed
        #
        # Arguments:
        #     name        Name of the resource
        #     amount      Amount to acquire
        #
        # Returns:
        #     None
        #
        # start modifications 
            package require math::numtheory
            package require math::constants
            package require math::trig
            package require math
            namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
            set tclprecision 17
            console show
            # following dresses up console output to easy eye
            console eval {.console config -bg palegreen}
            console eval {.console config -font {fixed 20 bold}}
            console eval {wm geometry . 40x20}
            console eval {.console config -background palegreen -highlightcolor tan -relief raised -border 30 }
            # changes: shifted text, removed empty lines, added easy eye console to deck.
            # changes: ran text through autoindent of ASED  TCL editor
        # end modifications
        proc acquire {name amount} {
            upvar 1  objectID ID
            upvar #0 $name resource_name
            puts "Acquiring $amount of $name for $ID ..."
            if { $resource_name >= $amount } {
                set resource_name [expr {$resource_name - $amount}]
            } else {
                puts "Waiting for $name -- $ID"
                while {1} {
                    set ::queue($name) [linsert $::queue($name) 0 $ID]
                    yield [list acquire $name $ID]
                    puts "Checking $name ..."
                    if { $resource_name >= $amount } {
                        set resource_name [expr {$resource_name - $amount}]
                        break
                    }
                    puts "Wait again - $name - $resource_name -- $amount ..."
                }
            }
            puts "Acquired $amount of $name for $ID"
        }
        # release --
        #     Release resources
        #
        # Arguments:
        #     name        Name of the resource
        #     amount      Amount to release
        #
        # Returns:
        #     None
        #
        proc release {name amount} {
            upvar 1  objectID ID
            upvar #0 $name resource_name
            set resource_name [expr {$resource_name + $amount}]
            puts "Releasing $amount of $name for $ID"
            if { [llength $::queue($name)] != 0 } {
                set hid   [lindex $::queue($name) 0]
                set ::queue($name) [lrange $::queue($name) 1 end]
                set ::events [linsert $::events 0 [list $hid acquire 0.0]]
            }
            puts "Released $amount of $name for $ID"
        }
        # resource --
        #     Create a named resource
        #
        # Arguments:
        #     name        Name of the resource
        #     amount      Amount to create
        #
        # Returns:
        #     None
        #
        proc resource {name amount} {
            upvar #0 $name resource_name
            set resource_name $amount
            set ::queue($name) {}
        }
        # hold --
        #     Advance the time for the given object in the simulation
        #
        # Arguments:
        #     delay       Time to advance
        #
        # Returns:
        #     None
        #
        proc hold {delay} {
            upvar 1 objectID object
            lappend ::events [list $object "hold" [expr {$::time+$delay}]]
            puts "Holding for $delay seconds ... $object"
            yield
            puts "Done"
        }
        # object --
        #     Create an object and schedule it's coming alive
        #
        # Arguments:
        #     procedure      Name of the procedure holding the life cycle
        #     time           Time at which it comes alive
        #
        # Returns:
        #     Structure representing the object
        #
        proc object {procedure time} {
            set obj [list $procedure $::objectno]
            lappend ::events [list $obj "init" $time]
            incr ::objectno
            return $obj
        }
        # handleEvents --
        #     Handle the events that were scheduled
        #
        # Arguments:
        #     None
        #
        # Returns:
        #     None
        #
        proc handleEvents {} {
            global time
            global events
            while { [llength $events] > 0 } {
                set count 0
                set found 0
                foreach event $events {
                    foreach {obj type eventTime} $event {break}
                    if { $eventTime <= $time } {
                        set events [lreplace $events $count $count]
                        set found  1
                        break
                    }
                    incr count
                }
                if { ! $found } {
                    foreach {obj type eventTime} [lindex $events 0] {break}
                    set events [lrange $events 1 end]
                }
                if { $time < $eventTime } {
                    set time $eventTime
                }
                if { $type == "init" } {
                    coroutine [lindex $obj 1] {*}$obj
                }
                if { $type == "hold" } {
                    puts "Releasing hold: $obj"
                    $obj
                }
                if { $type == "acquire" } {
                    puts "Continue acquiring: $obj"
                    $obj
                }
            }
        }
        # startSimulation --
        #     Start the simulation
        #
        # Arguments:
        #     None
        #
        # Returns:
        #     None
        #
        proc startSimulation {} {
            if { [llength $::events] == 0 } {
                return
            } else {
                handleEvents
            }
        }
        # boat --
        #     Simulate a boat that requires several tugs to get into the harbour
        #
        # Arguments:
        #     objectID             ID of the object (required name!)
        #
        # Returns:
        #     None
        #
        proc boat {objectID} {
            acquire tugs 2
            hold 10
            release tugs 2
        }
        # main --
        #     Simulate two objects that need the same resources
        #
        # Initialise simulation system
        set objectno 0
        set time   0.0
        set events {}
        # The simulation itself
        resource tugs 3
        set b1 [object boat 1.0]
        set b2 [object boat 4.0]
        startSimulation

gold 9/10/2020. added pix.


Discrete event modelling with coroutines screenshot tugboats moore


Equivalent One Liners V2


Beginning in the sixties, the one liner program was typed input to the command line of an operating computer system terminal so that the one line command performs some useful function in a single one line of terminal input. Some of the original one liner commands were limited to a 60 character display on especially the early Basic terminals or to a 72 characters on the Fortran punched cards. Of course, the hit return to send, terminal flashing bulbs, and automatic answer back were silently understood as part or supporting the one liner program. Some of the line lengths in some computer languages were later extended to 410 lines and so on. The definition and use of the one liner program has been widened to include program source for any language that does something useful in one line. On batch programs, controlling and setting variable statements like RETURN, STOP, END, extra terminal prompts, and setting initial variables were used in Fortran systems. Of course, a very good feature of TCL is that new variables as number types do not have to be initialized prior to use and no subroutine RETURN and END statements are necessary, vis the older Fortran and Basic dogmas in moldy textbooks. Repeating, setting a new number variable to 0 or 1 is not necessary prior to using the variable. Since a partial and practical goal of computer programming is to produce human readable code, it is permissible on the published console batch programs here to retain some vestigial stages to aid human comprehension.


Timing Equivalent One Liners V2

        # pretty print from autoindent and ased editor
        # Timing Equivalent One Liners V2
        # written on Windows 10 on eTCL
        # working under TCL version 8.6
        # gold on TCL Club , 8/20/2020
        # Ref. WIKI BOOKS, Tcl_Programming_Introduction
        # Book Section  contrasts one liners
        # versus  traditional procedural  approach
        # below contains redundant procs
        package require Tk
        package require math::numtheory
        package require math::constants
        package require math::trig
        package require math
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
        set tcl_precision 17
        proc pie {} {return [expr acos(-1)]}
        console show
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        #  uses join, but computer time on some?
        proc mean_1  list {expr double([join $list +])/[llength $list]}
        # math operators exposed as commands, and the expand operator
        proc mean_2  list {expr {[tcl::mathop::+ {*}$list]/double([llength $list])}}
        #  import the tcl::mathop operators
        proc mean_3 list {expr {[+ {*}$list]/double([llength $list])}}
        #  import the tcl::mathop operators from <Summing a list>
        # list add ladd or summing a list
        proc ladd_1 {listx} {::tcl::mathop::+ {*}$listx}
        # using join in ladd_2 from RS
        proc ladd_2 {listx} {expr [join $listx +]+0} ;# RS
        # using expr including non integers from PYK 2016-04-13
        proc ladd_3 {listx} {set total 0.0; foreach nxt $listx {set total [expr {$total + $nxt}]}; return $total}
        set limit 12
        puts "%|table| | printed in|TCL format |% "
        puts "&| session| proc &  mean value| elements in list  | comment, if any|& "
        for { set i 0 } { $i <= $limit }  { incr i } {
            set lister { 1 2 4 5 6 7 8 9 10 }
            lappend lister  [* $i [pie]]
            puts "&|$i | ladd_1   [ ladd_1  $lister ] |  $lister | proc timer [ time { set qq  [ ladd_1  $lister ]} 5000 ]  |&"
            puts "&|$i | ladd_2   [ ladd_2  $lister ] |  $lister | proc timer [ time { set qq  [ ladd_2  $lister ]} 5000 ]  |&"
            puts "&|$i | ladd_3   [ ladd_3  $lister ] |  $lister | proc timer [ time { set qq  [ ladd_3  $lister ]} 5000 ]  |&"
            puts "&|$i | mean_1   [ mean_1  $lister ] |  $lister | proc timer [ time { set qq  [ mean_1  $lister ]} 5000 ]  |&"
            puts "&|$i | mean_2   [ mean_2  $lister ] |  $lister | proc timer [ time { set qq  [ mean_2  $lister ]} 5000 ]  |&"
            puts "&|$i | mean_3   [ mean_3  $lister ] |  $lister | proc timer [ time { set qq  [ mean_3  $lister ]} 5000 ]  |&"
            puts "&|$i | ::math::mean  [::math::mean  1  2  4  5  6  7  8  9  10 [* $i [pie]]] |  $lister | proc timer [ time { set qq    [ ::math::mean  1  2  4  5  6  7  8  9  10 [* $i [pie]] 5000 ]}  ]  |&"
        }
        #end        

Table of Timing 4 Procs

table printed inTCL format
session proc & mean value elements in list comment, if any
0 ladd_1 52.0 1 2 4 5 6 7 8 9 10 0.0 proc timer 2.3273999999999999 microseconds per iteration
0 ladd_2 52.0 1 2 4 5 6 7 8 9 10 0.0 proc timer 5.6311999999999998 microseconds per iteration
0 ladd_3 52.0 1 2 4 5 6 7 8 9 10 0.0 proc timer 4.3941999999999997 microseconds per iteration
0 mean_1 5.2000000000000002 1 2 4 5 6 7 8 9 10 0.0 proc timer 13.053599999999999 microseconds per iteration
0 mean_2 5.2000000000000002 1 2 4 5 6 7 8 9 10 0.0 proc timer 3.0369999999999999 microseconds per iteration
0 mean_3 5.2000000000000002 1 2 4 5 6 7 8 9 10 0.0 proc timer 2.3805999999999998 microseconds per iteration
0 ::math::mean 5.2000000000000002 1 2 4 5 6 7 8 9 10 0.0 proc timer 22 microseconds per iteration
1 ladd_1 55.141592653589797 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 1.7847999999999999 microseconds per iteration
1 ladd_2 55.141592653589797 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 7.3037999999999998 microseconds per iteration
1 ladd_3 55.141592653589797 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 1.7285999999999999 microseconds per iteration
1 mean_1 5.5141592653589795 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 8.3374000000000006 microseconds per iteration
1 mean_2 5.5141592653589795 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 2.2898000000000001 microseconds per iteration
1 mean_3 5.5141592653589795 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 2.1674000000000002 microseconds per iteration
1 ::math::mean 5.5141592653589795 1 2 4 5 6 7 8 9 10 3.1415926535897931 proc timer 6 microseconds per iteration
2 ladd_1 58.283185307179586 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 1.7618 microseconds per iteration
2 ladd_2 58.283185307179586 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 6.6627999999999998 microseconds per iteration
2 ladd_3 58.283185307179586 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 4.0709999999999997 microseconds per iteration
2 mean_1 5.8283185307179588 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 8.5307999999999993 microseconds per iteration
2 mean_2 5.8283185307179588 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 2.1261999999999999 microseconds per iteration
2 mean_3 5.8283185307179588 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 2.3512 microseconds per iteration
2 ::math::mean 5.8283185307179588 1 2 4 5 6 7 8 9 10 6.2831853071795862 proc timer 5 microseconds per iteration
3 ladd_1 61.424777960769376 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 1.9702 microseconds per iteration
3 ladd_2 61.424777960769376 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 7.1285999999999996 microseconds per iteration
3 ladd_3 61.424777960769376 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 2.6114000000000002 microseconds per iteration
3 mean_1 6.1424777960769372 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 8.5581999999999994 microseconds per iteration
3 mean_2 6.1424777960769372 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 2.1989999999999998 microseconds per iteration
3 mean_3 6.1424777960769372 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 2.4533999999999998 microseconds per iteration
3 ::math::mean 6.1424777960769372 1 2 4 5 6 7 8 9 10 9.4247779607693793 proc timer 5 microseconds per iteration
4 ladd_1 64.566370614359172 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 1.7842 microseconds per iteration
4 ladd_2 64.566370614359172 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 10.103400000000001 microseconds per iteration
4 ladd_3 64.566370614359172 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 1.9608000000000001 microseconds per iteration
4 mean_1 6.4566370614359174 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 8.8523999999999994 microseconds per iteration
4 mean_2 6.4566370614359174 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 2.0948000000000002 microseconds per iteration
4 mean_3 6.4566370614359174 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 2.2736000000000001 microseconds per iteration
4 ::math::mean 6.4566370614359174 1 2 4 5 6 7 8 9 10 12.566370614359172 proc timer 5 microseconds per iteration
5 ladd_1 67.707963267948969 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 3.6421999999999999 microseconds per iteration
5 ladd_2 67.707963267948969 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 10.6218 microseconds per iteration
5 ladd_3 67.707963267948969 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 2.3553999999999999 microseconds per iteration
5 mean_1 6.7707963267948967 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 8.4225999999999992 microseconds per iteration
5 mean_2 6.7707963267948967 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 2.1343999999999999 microseconds per iteration
5 mean_3 6.7707963267948967 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 2.1093999999999999 microseconds per iteration
5 ::math::mean 6.7707963267948967 1 2 4 5 6 7 8 9 10 15.707963267948966 proc timer 5 microseconds per iteration

bits and pieces, Testing One Liner Programs


      set  strinit “123456789”
      proc string_end strin5 { string index $strin5 end}
      string_end $strinit 
      # out  9
      proc sea5 bb { set i 2;if {$i < 10} { while {$i < 5} { puts [incr i]}}}
      sea 5
      # return first character of string
      proc string_end5 bb  { string index $bb 0 }
      # return last character of string
      proc string_end5 bb  { string index $bb end }
            # Enter number num for next above power of 2, John K. Ousterhout, Tcl and the Tk Toolkit
            proc near_above_power_of_2  num {set pow 1; while {$pow<$num} {set pow [expr { $pow*2} ]}; return $pow}
            # Usage  near_above_power_of_2 7 returns 8,
            # Usage  near_above_power_of_2 9 returns 16,
            # Usage near_above_power_of_2 99999999999999 140737488355328
            # Enter number num for next below power of 2, John K. Ousterhout, Tcl and the Tk Toolkit
            proc near_below_power_of_2  num {set pow 1; while {$pow< [expr {$num - 1}] } {set pow [expr { $pow*2} ]}; return [expr { $pow*.5} ]}
            # Usage  near_below_power_of_2  7 returns 4.            

# start advice file.
AMG: The return value of a Tcl procedure is inherited from the return value of the last command to execute within that procedure. Therefore, many uses of the [return] command are redundant. For example, this procedure:

proc anglecosa {a b c} {return [expr {($b*$b+$c*$c-$a*$a)/(2.*$b*$c)}]}
can be written more simply:

proc anglecosa {a b c} {expr {($b*$b+$c*$c-$a*$a)/(2.*$b*$c)}}
Also, the conditional arguments to [if], [while], [for] are already expr-essions, so there's no need to nest a call to [expr]. For example,

proc emmy2 {} {if {[expr {rand()}] <= 0.9} {return 1}}
can be simplified quite a lot:

proc emmy2 {} {if {rand() <= 0.9} {return 1}}
#end of advice file


Appendix Code

Trial Console Program

        # TCL source code follows
        # ASED autoindent applied
        # Trial Console Program  brackets and quotes.
        # written on Windows XP on TCL
        # working under TCL version 8.6
        # gold on TCL Club, 12Dec2018
        console show
        puts " result value is [expr { 1+3} ] ";
        puts [expr { 1+3} ];
        # creating list
        set lister1 [ list  dog cat lizard ] ;
        puts $lister1;
        set lister2 {" dog cat lizard" };
        puts $lister2;
        #  $lister2 is really a string of 3 items
        # but some list coomands lappend and lindex may
        # interpret $lister2 as list
        set lister3 {" dog cat”  lizard };
        puts $lister3;
        set lister4 " dog cat lizard" ;
        $lister4;
        # note outputs are similar
        # for $lister1 and $lister4
        # gold on TCL Club, 12Dec2018
           

Code Scraps


gold 9/24/2021. updated examples


      # The easy way is to start with proper list command
      set list_fruit [ list apple pear orange grape ]
      lappend $list_fruit peach
      # The hard way is to start with individual strings of characters
      set a1 apple
      set a2 pear 
      set a3 orange
      set a4 grape
      set a5 peach
      set list_fruit_assembly [ list $a1 $a2 $a3 $a4 ]  
      lappend list_fruit_assembly $a5   
      # begin code for TCL wiki table format 
      proc wiki_table_format  { start finish  } {
      # TCL wiki table format  
      # set numers in TCL wiki table format  
      # use equivalent TCL procedure all the time for tables in wikis            
      set first $start 
      set last $finish
      set list_numbers [ list &| ]
      while {$first < $last } {
      lappend list_numbers entry No. $first =  $first |
      incr first
      } 
      lappend list_numbers comments  |&
      puts  $list_numbers
      # &| entry No. 1 = 1 | entry No. 2 = 2 | entry No. 3 = 3 | entry No. 4 = 4 | entry No. 5 = 5 | entry No. 6 = 6 | entry No. 7 = 7 | entry No. 8 = 8 | entry No. 9 = 9 | comments |& }
       wiki_table_format   1 10  
      # &| 8191 24574 12287 36862 :|  collatz_sequence_head   : |  | |& /
      &| 8 4 2 1 :|  collatz_sequence_tail :  |  | |& /
      &| 159 :|  collatz_sequence_length: |  | |&


scratch


      proc near_above_power_of_2x  num {set pow 1; while {$pow<$num} {set pow [expr { $pow*2} ]}; return $pow}
      proc near_above_power_of_2  num {set pow 1; while {$pow<$num} {set pow [expr { $pow*2} ]}; return $pow}
      proc ld x "expr {log(\$x)/[expr log(2)]}" ;# RS
            [pow 2 [+ [int 2.8] 1]]= "8.0"
      proc zap x "[pow 2 [+ 1 [expr {log(\$x)/[expr log(2)]}]"
      proc zap x "pow 2 [+ [int 2.8] 1]"

One Liners from www.codecodex.com/wiki

        #under test from www.codecodex.com/wiki
        set lister { 1 2 4 5 6 7 8 9 10 }
        set s {starchild}
        package require struct::list
        proc reverseWords s {return [struct::list reverse [split $s]]}
        proc ! n {expr {$n<2? 1: $n*[! [incr n -1]]}}
        # usage    ! 5  returns 120
        proc average list {expr ([join $list +])/[llength $list].}
        for {set i 1} {$i <= 1000} {incr i} {pust [expr {$i*($i+1)/2}]}
        namespace import ::tcl::mathop::*
        proc average list {expr {[+ {*}$list]/double([llength $list])}}
        # works here , average $lister returns 5.777777777777778
        proc fib n {expr {$n<2? $n: [fib [incr n -1]] + [fib [incr n -1]]}}
        # not working here 
        namespace import ::tcl::mathfunc::*
        ::tcl::mathfunc::isqrt 26
        # ::tcl::mathfunc::isqrt 26  returns 5, working here        
        set date [clock format [clock scan $date] -format {%Y-%m-%d %H:%M:%S}] ;#dclaar 
        scriptEval clock format [clock scan $tDate] -format {%Y-%m-%d %H:%M:%S} ;#dclaar 
        # clock scan is your friend; it knows all sorts of formats. In 
        # case above, it converts: Oct 15 06:52:45 2009 to: 2009-10-15 06:52:45

Testing One Liner Program for list_twin_primes V2


        # pretty print from autoindent and ased editor
        # list_twin_primes V2
        # written on Windows 10 on TCL
        # working under TCL version 8.6
        # gold on TCL Club , 8/20/2020
        # Ref. WIKI BOOKS, Tcl_Programming_Introduction
        # Book Section  contrasts one liners
        # versus  traditional procedural  approach
        # below contains redundant procs
        package require Tk
        package require math::numtheory
        package require math::constants
        package require math::trig
        package require math
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
        set tcl_precision 17
        proc pie {} {return [expr acos(-1)]}
        console show
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        # invoking TCLLIB math::numtheory
        proc isprimex x {expr {$x>1 && ![regexp {^(oo+?)\1+$} [string repeat o $x]]}}
        # list_twin_primes proc  under test, list_twin_primes and isprime procs are recursion limited
        proc list_twin_primesx { aa bb cc} { for {set i $aa} {$i<=$bb} {incr i $cc} { if {[isprime $i] && [isprime [+ $i $cc ]] } {lappend  boo  $i [+ $i $cc ]  } } ; return $boo}
        proc list_twin_primes { aa bb cc} { for {set i $aa} {$i<=$bb} {incr i 1} { if {[isprime $i] && [isprime [+ $i $cc ] ] } {  lappend  boo  $i  [+ $i $cc ]   } } ; return $boo}
        # aa is start number, bb is upper limit, cc is separator number, usually even 2
        # The original Dickson conjecture has separator even numbers 2,4,6 ... ?
        # list_twin_primes 0 25 2 returns 3 5 5 7 11 13 17 19
        # The sets <13 15> and <15 17> are separated by a even 2,
        # but left out of answer.
        # Note the 15 is not a prime number and has factors <3 5>.
        # The set <13 17> has two primes, but separated by an even 4.
        # reference On-Line Encyclopedia of Integer Sequences website
        # OEIS A077800 discussed that the twin prime sets <p,p+2> are
        # (3, 5), (5, 7), (11, 13), (17, 19),
        # (29, 31), (41, 43), (59, 61), (71, 73),
        # (101, 103), (107, 109), (137, 139)...
        # OEIS A275021 has  samples of <p,p+4> and omits pairs of <p,p+2>
        # 79, 83, 127, 131, 163, 167, 379, 383, 397, 401, 439, 443,...
        # list_twin_primes 75 135 4 returns 79 83 103 107 127 131
        # reference On-Line Encyclopedia of Integer Sequences website
        # OEIS A023201 has some samples of <p,p+6> 
        # 5, 7, 11, 13, 17, 23, 31, 37, 
        # 41, 47, 53, 61, 67, 73, 83, 97, 101
        # contains redundant procs for testing
        puts "[list_twin_primes 3 25 2 ]"
        puts "[list_twin_primes 3 25 4 ]"
        puts "[list_twin_primes 3 25 6 ]"

Table Results on Twin Primes for 2,4,6,10 Separators


table Twin Primes for 2,4,6,10 Separators printed inTCL format
result lower limit upper limit separator integer comment, if any
elements in list lower limit upper limit separator integer comment, if any
3 5 5 7 11 13 17 19 3 25 2
3 7 7 11 13 17 19 23 3 25 4
5 11 7 13 11 17 13 19 17 23 23 29 3 25 6
3 13 7 17 13 23 19 29 3 25 10

Older TCL4 reserve

gold Here are some one line procedures for circle area and law of cosines. See tcl::mathfunc cos pi constants Functions ::math::constants::constants and ::math::fibonacci are available in the TCLLIB.


   proc pi {} {expr {acos(-1)}}  #from AMG see below
   proc degtoradiansconst {} {return [ expr {180./[pi]}  ]}
   proc degz {} {return [ expr {180./[pi]}  ]}
   proc degx {aa} {return [ expr { [degz]*acos($aa) }  ]}
   proc inrad {a b c} {return  [expr {(sqrt(($a+$b+$c)*($a+$b-$c)*($a-$b+$c)*($b+$c-$a)))/(2.*($a+$b+$c)) } ] }
   proc circlediameter {radius} { return [ expr { 2.* $radius } ] }
   proc circlearea {radius} { return  [  expr { [pi]*($radius**2) }]}
   proc circlecircumference   {radius} {return [ expr {2.*[pi]*$radius }]}
   proc spherediameter  {radius}  {return  [ expr { 2.* $radius }]}
   proc spherevolume   {radius}  { return [ expr { (4./3.)*[pi]*($radius**3) }]}
   proc spheresurface    {radius} { return [ expr { 4.*[pi]*($radius**3) }]}
   proc cubevolume {aa}  { return [ expr { 1.*$aa*$aa*$aa } ] }
   proc squarearea  {aa}  { return [ expr { 1.*$aa*$aa } ] }
   proc ellipsoidvolume {aa bb cc} { return [ expr { 1.*(4./3.)*[pi]*$aa*$bb*$cc } ] }
   proc ellipsearea1 { aa bb } {return [ expr { 1.*[pi]*$aa*$bb  } ]}
   proc ellipseperimeterx {aa bb} { set tt [ expr { ($aa*$aa+$bb*$bb)/2.}];return [ expr { 2.*[pi]*sqrt($tt)} ] }
   proc spherevolumex {aa  } { return [ expr { 1.*(4./3.)*[pi]*$aa*$aa*$aa } ] }
   proc spheroidvolumex {aa cc } { return [ expr { 1.*(4./3.)*[pi]*$aa*$aa*$cc } ] }
   proc torusvolumex {aa bb }  { return [ expr {(1./4.)  *[pi]*[pi] * ($aa + $bb) * ($aa - $bb)*2.}] }
   proc torussurfacex {aa bb }  { return [ expr { [pi]*[pi] *  ($aa*$aa - $bb*$bb) }] } 
   proc conesurfacex {aa rr }  { return [ expr { [pi]*$rr*$aa}] }
   proc cylindersurfacesidex {aa rr }  { return [ expr {2.* [pi]*$rr*$aa}] }   
   proc cylinderwholesurfacesidex {aa rr }  { return [ expr {2.* [pi]*$rr*$aa +2.*[pi]*$rr*$rr}] }   
   proc cylindervolumesidex {aa rr }  { return [ expr { [pi]*$rr*$rr*$aa}] } 
   proc conevolumex {aa rr }  { return [ expr { (1./3.)*[pi]*$rr*$rr*$aa}] } 
   proc pyramidvolumex {aa bb cc }  { return [ expr { (1./3.)*$aa*$bb*$cc  }] } 
   proc rectangularprismvolumex {aa bb cc }  { return [ expr { $aa*$bb*$cc  }] } 
   proc triangularprismvolumex {aa bb cc }  { return [ expr { $aa*$bb*$cc*.5  }] } 
   proc polygonperimeterx {aa bb }  { return [ expr { $aa*$bb}] } 
   proc rectangleperimeterx {aa bb }  { return [ expr {2.*( $aa+$bb)}] } 
   proc parallelogramperimeterx {aa bb }  { return [ expr {2.*( $aa+$bb)}] } 
   proc triangleperimeterx {aa bb cc}  { return [ expr { $aa+$bb+$cc }] } 
   proc triangletrapezoidx {aa bb cc}  { return [ expr { $aa*($bb+$cc)*(1./2.) }] }
   #law of cosines, aa bb cc are three sides of right triangle, here ordered 
   #as aa small side , bb middle side, cc largest side.
   # inrad is radius of cirle inscribed in right triangle,
   # use sides as inrad aa bb cc 
   proc anglecosa  { aa bb cc } {return [ expr {  ($bb*$bb+$cc*$cc-$aa*$aa)/(2.*$bb*$cc) }]}
   proc anglecosb { aa bb cc }  {return [ expr {  ($cc*$cc+$aa*$aa-$bb*$bb)/(2.*$aa*$cc) }]}
   proc anglecosc { aa bb cc } { return [ expr {  ($aa*$aa+$bb*$bb-$cc*$cc)/(2.*$aa*$bb) }]}
   #with examples
   #for radius of 1
   #circlediameter 1 
   #circlearea 1  
   #circlecircumference 1  
   #spherediameter 1   
   #spherevolume 1 
   #spheresurface 1 
   #inrad 3 4 5 
   #anglecosa 3 4 5 
   #anglecosb 3 4 5  
   #anglecosc 3 4 5
   # following include redundant TCL one liner procedures for  sqrt of sum of squares
   #   sqrt of sum of squares and diagonal using expr 
   proc diagonal_1  {aa bb} {[expr { sqrt($aa * $aa + $bb * $bb)}] }
   # Usage diagonal 1 1 returns  1.4142135623730951
   # diagonal using math ops
   proc diagonal_2 {aa bb} {[sqrt [+ [* $aa $aa]  [* $bb  $bb] ] ]}
   # Usage  diagonal_2 1 1 returns 1.4142135623730951
   # diagonal using math hypot function
   proc diagonal_3{aa bb} {[ hypot $aa $bb ]}
   # Usage  diagonal_3 1 1 returns 1.4142135623730951
   # time one liners, but sticking >> [ time { set qq  [ diagonal_1  1 1 ] }  ]
   proc diagonal_1x {aa bb} { [ time [sqrt [+ [* $aa $aa]  [* $bb  $bb] ] ]]}

Sample of TCL One Liner Procedures V2


        # Sample of TCL One Liner Procedures  V2
        # written on Windows 10 on TCL 8.6
        # working under TCL version 8.6
        # gold on TCL Club , 9/20/2020
        # Ref. WIKI BOOKS, Tcl_Programming_Introduction pdf
        # Book Section  contrasts one liners procedures
        # versus  traditional procedural  approach.
        # Below contains redundant One Liner procedures
        # to contrast alternate techniques and constructs
        # start modifications
        package require Tcl 8.6
        package require math::numtheory
        package require math::constants
        package require math::trig
        package require math
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
        set tclprecision 17
        console show
        # following dresses up console output to easy eye
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        puts "Admiral begins operations "
        # changes: shifted text, removed empty lines, added easy eye console to deck.
        # end modifications
        console show
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        namespace path {::tcl::mathop ::tcl::mathfunc}
        # contains redundant procs for testing one liner procedures V2
        proc pi {} {expr {acos(-1)}}
        # proc pi from AMG see below
        proc degtoradiansconst {} { expr {180./ [pi] }}
        proc degz {} { expr {180./ [pi] }}
        proc degx {aa} { expr { degz *acos($aa)}}
        proc inrad {a b c} { expr {(sqrt(($a+$b+$c)*($a+$b-$c)*($a-$b+$c)*($b+$c-$a)))/(2.*($a+$b+$c))}}
        proc circlediameter {radius} { expr { 2.* $radius }}
        proc circlearea {radius} { expr { [pi] *($radius**2)}}
        proc circlecircumference   {radius} { expr {2.* [pi]  *$radius }}
        proc spherediameter {radius} { expr { 2.* $radius }}
        proc spherevolume {radius} { expr { (4./3.)* [pi]  *($radius**3)}}
        proc spheresurface {radius} { expr { 4.* [pi]  *($radius**3)}}
        proc cubevolume {aa}  { expr { 1.*$aa*$aa*$aa }}
        proc squarearea  {aa}  { expr { 1.*$aa*$aa }}
        proc ellipsoidvolume {aa bb cc} { expr { 1.*(4./3.)* [pi] *$aa*$bb*$cc }}
        proc ellipsearea1 { aa bb } { expr { 1.* [pi]  *$aa*$bb  }}
        proc ellipseperimeterx {aa bb} { set tt [ expr { ($aa*$aa+$bb*$bb)/2.}];return [ expr { 2.*[pi]*sqrt($tt)} ] }
        proc spherevolumex {aa } { expr { 1.*(4./3.)* [pi]  *$aa*$aa*$aa }}
        proc spheroidvolumex {aa cc } { expr { 1.*(4./3.)* [pi]  *$aa*$aa*$cc }}
        proc torusvolumex {aa bb } { expr {(1./4.) * [pi] * [pi] * ($aa + $bb) * ($aa - $bb)*2.}}
        proc torussurfacex {aa bb } { expr { [pi] * [pi] * ($aa*$aa - $bb*$bb)}}
        proc conesurfacex {aa rr } { expr { [pi]  *$rr*$aa}}
        proc cylindersurfacesidex {aa rr } { expr {2.* [pi] *$rr*$aa}}
        proc cylinderwholesurfacesidex {aa rr } { expr {2.* [pi] *$rr*$aa +2.* [pi]  *$rr*$rr}}
        proc cylindervolumesidex {aa rr } { expr { [pi] *$rr*$rr*$aa}}
        proc conevolumex {aa rr }  { expr { (1./3.)* [pi] *$rr*$rr*$aa}}
        proc pyramidvolumex {aa bb cc } { expr {(1./3.)*$aa*$bb*$cc }}
        proc rectangularprismvolumex {aa bb cc } { expr { $aa*$bb*$cc }}
        proc triangularprismvolumex {aa bb cc } { expr { $aa*$bb*$cc*.5 }}
        proc polygonperimeterx {aa bb } { expr { $aa*$bb}}
        proc rectangleperimeterx {aa bb } { expr {2.*( $aa+$bb)}}
        proc parallelogramperimeterx {aa bb } { expr {2.*( $aa+$bb)}}
        proc triangleperimeterx {aa bb cc} { expr { $aa+$bb+$cc }}
        proc triangletrapezoidx {aa bb cc} { expr { $aa*($bb+$cc)*(1./2.)}}
        #law of cosines, aa bb cc are three sides of right triangle, here ordered
        #as aa small side , bb middle side, cc largest side.
        # inrad is radius of cirle inscribed in right triangle,
        # use sides as inrad aa bb cc
        proc anglecosa  { aa bb cc } { expr {($bb*$bb+$cc*$cc-$aa*$aa)/(2.*$bb*$cc)}}
        proc anglecosb { aa bb cc } { expr {($cc*$cc+$aa*$aa-$bb*$bb)/(2.*$aa*$cc)}}
        proc anglecosc { aa bb cc } { expr {($aa*$aa+$bb*$bb-$cc*$cc)/(2.*$aa*$bb)}}
        #with examples
        #for radius of 1
        #circlediameter 1
        #circlearea 1
        #circlecircumference 1
        #spherediameter 1
        #spherevolume 1
        #spheresurface 1
        #inrad 3 4 5
        #anglecosa 3 4 5
        #anglecosb 3 4 5
        #anglecosc 3 4 5
        # following include redundant TCL one liner procedures for  sqrt of sum of squares
        #   sqrt of sum of squares and diagonal using expr
        proc diagonal_1  {aa bb} { expr { sqrt($aa * $aa + $bb * $bb)}}
        # Usage diagonal 1 1  s  1.4142135623730951
        # maturity value of loan using TCL 8.6 math ops, 10Sep2020
        # similar formula for time in days divide years by 360.
        # similar formula for interest rate in percent, divide interest by 100.
        # should work with any currency and just use consistent units.
        # maintain isolating spaces in TCL math ops
        proc maturity_value_loan { principal interest years} { [*  $principal  [+ 1. [* 1. $interest $years ]]] }
        # Usage  maturity_value_loan 100. .05 1. returns 105.
        proc maturity_value_loan_percent { principal percent_i years} { [*  $principal  [+ 1. [* 1. [/  $percent_i 100.]  $years ]]] }
        # Usage  maturity_value_loan_percent 100. 5. 1. returns 105.
        proc maturity_value_loan_days { principal interest days} { [*  $principal  [+ 1. [* 1. $interest [/ $days 360. ]]]] }
        # Usage  maturity_value_loan_days 100. .05 360. returns 105.
        # following proc session invoke TCLLIB math::trig library
        proc pyramid_d {hh bb} { [ acotand [expr (.5*$bb/$hh) ]] }
        proc pyra_d {hh bb} { [ acotand [* .5 [/ $bb $hh] ]] }
        # Usage pyramid_degrees 57.692 106.346 answer 47.334157521261254
        # hh is height of pyramid, units cancel out
        # bb is base length of pyramid
        # seked = (7 * .5 * 360 cubits) / 250 cubits = 5.04 decimal palms
        proc seked_d {hh bb} { [/ [* 7. .5 $bb ] $hh ] }
        # usage seked_d 250. 360. equals 5.04
        # end TCLLIB
        # hbA1c_convert_to_average_blood_glucose mg/dl  HbA1c
        proc a1c hbA1c {  expr { 35.6*$hbA1c -77.3} }
        # convert mg/dl to mmol/L average blood glucose
        # some papers round off 18.016 to mgdl/18.
        proc mgdl_to_mmoll mgdl {  expr { $mgdl/18.0 } }
        # convert  mmol/L to mg/dl average blood glucose
        proc mmoll_to_mgdl mmoll {  expr { $mmoll*18.0 } }
        # *************************************8
        #  mean_speed_1 is defined as apparent velocity
        # of Jupiter along Zodiac in degrees per day
        # mean_speed_1 = [ expr { .5 * (velocity_1 - velocity_0 )} ]
        proc mean_speed_1 {velocity_1  velocity_0} {  expr { .5 * ($velocity_1 - $velocity_0 )}   }
        # Usage  mean_speed_1 1.5 .5 for 1.5 and 0.5 speeds in degrees per day returns 1. 
        # *******************************
        # adding_two_fractions aa/bb + cc/dd = 
        # ((aa *dd*1.))+(bb*cc*1.))/(bb*dd*1.),
        # but must insert 1. factor to return real numbers in TCL math ops
        proc adding_two_fractions { aa bb cc dd } {  [/ [+  [*  $aa $dd 1. ]  [* $bb $cc 1. ]] [* $bb $dd 1.] ] }
        # suggest maintain spaces in math ops
        # Usage adding_two_fractions 1.0 1.0 1.0 1.0 returns   2.0
        # Usage adding_two_fractions 1 1 1 1  returns   2.0
        # Usage adding_two_fractions 1. 2. 1. 2. returns   1.0 
        # subtracting_two_fractions aa/bb - cc/dd = 
        # ((aa *dd*1.))-(bb*cc*1.))/(bb*dd*1.),
        # but must insert 1. factor to return real numbers in TCL math ops
        proc subtracting_two_fractions { aa bb cc dd } {  [/ [-  [*  $aa $dd 1. ]  [* $bb $cc 1. ]] [* $bb $dd 1.] ] }
        # subtracting_two_fractions 1. 2. 1. 4. returns 0.25
        # subtracting_two_fractions 1. 1. 1. 1. returns 0.0
        # subtracting_two_fractions 1 1 1 1 returns 0.0
        # multiplying_two_fractions  
         proc multiplying_two_fractions { aa bb cc dd } { [/  [* $aa $cc 1. ]   [* $bb $dd 1. ] ] }
        # multiplying_two_fractions 1. 2. 1. 2. returns  0.25
        # multiplying_two_fractions 1. 1. 1. 1. returns 1,0 
        # multiplying_two_fractions 1 1 1 1 returns  1.0
        # dividing_two_fractions
        # but must insert 1. factor to return real numbers in TCL math ops
        proc dividing_two_fractions { aa bb cc dd } { [/  [* $aa $dd 1. ]   [* $bb $cc 1. ] ] }
        # dividing_two_fractions 1. 1. 1. 2. returns 2.  
        # dividing_two_fractions 1. 1. 1. 1. returns 1.0 
        # dividing_two_fractions 1 1 1 1 returns 1.0 
        # ********************************
        proc bodes_law_1  { nn } {  return [+ 0.4 [* 0.3 [pow 2 $nn]]] }
        # Usage bodes_law_1 1 returns   1.0 Astronomical units for planet Earth
        # Usage bodes_law_1 2 returns   0.7 AU for planet Venus
        # Usage bodes_law_1 3 returns   1.6 AU for planet Mars
        proc bodes_law_2 {} { foreach nn {0 1 2 3 4 5 6 7} { lappend planets [+ 0.4 [* 0.3 [pow 2 $nn]]]};return $planets}
        # Usage  bodes_law_2  returns  list  0.7 1.0 1.6 2.8 5.2 10.0 19.59 38.8 
        puts " out  " 

    # pretty print from autoindent and ased editor
    # One Liners Procedures V2
    # written on Windows 10 on  TCL
    # working under TCL version 8.6
    # gold on TCL Club , 10Sep2020
    package require Tk
    package require math::numtheory
    package require math::constants
    package require math::trig
    package require math
    namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
    set tclprecision 17
    # following dresses up console output to easy eye
    console show
    console eval {.console config -bg palegreen}
    console eval {.console config -font {fixed 20 bold}}
    console eval {wm geometry . 40x20}
    console eval {wm title . " One Liners Report , screen grab and paste from console 2 to texteditor"}
    console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}
    # blank table addition
    puts "%|table |printed in| tcl wiki format|% "
    puts "&| quantity| value| comment, if any|& "
    puts "&| testcase number:|   |&"
    puts "&| value  |quantity 1 |   |&"
    proc pi {} {expr {acos(-1)}}
    # proc pi from AMG see below
    # ******surface and area calculations ******
    proc degtoradiansconst {} { expr {180./ [pi] }}
    proc degz {} { expr {180./ [pi] }}
    proc degx {aa} { expr { degz *acos($aa)}}
    proc inrad {a b c} { expr {(sqrt(($a+$b+$c)*($a+$b-$c)*($a-$b+$c)*($b+$c-$a)))/(2.*($a+$b+$c))}}
    proc circlediameter {radius} { expr { 2.* $radius }}
    proc circlearea {radius} { expr { [pi] *($radius**2)}}
    proc circlecircumference   {radius} { expr {2.* [pi]  *$radius }}
    proc spherediameter {radius} { expr { 2.* $radius }}
    proc spherevolume {radius} { expr { (4./3.)* [pi]  *($radius**3)}}
    proc spheresurface {radius} { expr { 4.* [pi]  *($radius**3)}}
    proc cubevolume {aa}  { expr { 1.*$aa*$aa*$aa }}
    proc squarearea  {aa}  { expr { 1.*$aa*$aa }}
    proc ellipsoidvolume {aa bb cc} { expr { 1.*(4./3.)* [pi] *$aa*$bb*$cc }}
    proc ellipsearea1 { aa bb } { expr { 1.* [pi]  *$aa*$bb  }}
    proc ellipseperimeterx {aa bb} { set tt [ expr { ($aa*$aa+$bb*$bb)/2.}];return [ expr { 2.*[pi]*sqrt($tt)} ] }
    proc spherevolumex {aa } { expr { 1.*(4./3.)* [pi]  *$aa*$aa*$aa }}
    proc spheroidvolumex {aa cc } { expr { 1.*(4./3.)* [pi]  *$aa*$aa*$cc }}
    proc torusvolumex {aa bb } { expr {(1./4.) * [pi] * [pi] * ($aa + $bb) * ($aa - $bb)*2.}}
    proc torussurfacex {aa bb } { expr { [pi] * [pi] * ($aa*$aa - $bb*$bb)}}
    proc conesurfacex {aa rr } { expr { [pi]  *$rr*$aa}}
    proc cylindersurfacesidex {aa rr } { expr {2.* [pi] *$rr*$aa}}
    proc cylinderwholesurfacesidex {aa rr } { expr {2.* [pi] *$rr*$aa +2.* [pi]  *$rr*$rr}}
    proc cylindervolumesidex {aa rr } { expr { [pi] *$rr*$rr*$aa}}
    proc conevolumex {aa rr }  { expr { (1./3.)* [pi] *$rr*$rr*$aa}}
    proc pyramidvolumex {aa bb cc } { expr {(1./3.)*$aa*$bb*$cc }}
    proc rectangularprismvolumex {aa bb cc } { expr { $aa*$bb*$cc }}
    proc triangularprismvolumex {aa bb cc } { expr { $aa*$bb*$cc*.5 }}
    proc polygonperimeterx {aa bb } { expr { $aa*$bb}}
    proc rectangleperimeterx {aa bb } { expr {2.*( $aa+$bb)}}
    proc parallelogramperimeterx {aa bb } { expr {2.*( $aa+$bb)}}
    proc triangleperimeterx {aa bb cc} { expr { $aa+$bb+$cc }}
    proc triangletrapezoidx {aa bb cc} { expr { $aa*($bb+$cc)*(1./2.)}}
    # law of cosines, aa bb cc are three sides of right triangle, here ordered
    # as aa small side , bb middle side, cc largest side.
    # inrad is radius of cirle inscribed in right triangle,
    # use sides as inrad aa bb cc
    proc anglecosa  { aa bb cc } { expr {($bb*$bb+$cc*$cc-$aa*$aa)/(2.*$bb*$cc)}}
    proc anglecosb { aa bb cc } { expr {($cc*$cc+$aa*$aa-$bb*$bb)/(2.*$aa*$cc)}}
    proc anglecosc { aa bb cc } { expr {($aa*$aa+$bb*$bb-$cc*$cc)/(2.*$aa*$bb)}}
    # with examples
    # for radius of 1
    # circlediameter 1
    # circlearea 1
    # circlecircumference 1
    # spherediameter 1
    # spherevolume 1
    # spheresurface 1
    # inrad 3 4 5
    # anglecosa 3 4 5
    # anglecosb 3 4 5
    # anglecosc 3 4 5
    # following include redundant TCL one liner procedures for  sqrt of sum of squares
    #   sqrt of sum of squares and diagonal using expr
    proc diagonal_1  {aa bb} { expr { sqrt($aa * $aa + $bb * $bb)}}
    # Usage diagonal 1 1  s  1.4142135623730951
    # *****    simple interest  section *******
    # maturity value of loan using TCL 8.6 math ops, 10Sep2020
    # similar formula for time in days divide years by 360.
    # similar formula for interest rate in percent, divide interest by 100.
    # should work with any currency and just use consistent units.
    # maintain isolating spaces in TCL math ops
    proc maturity_value_loan { principal interest years} { [*  $principal  [+ 1. [* 1. $interest $years ]]] }
    # Usage  maturity_value_loan 100. .05 1. returns 105.
    proc maturity_value_loan_percent { principal percent_i years} { [*  $principal  [+ 1. [* 1. [/  $percent_i 100.]  $years ]]] }
    # Usage  maturity_value_loan_percent 100. 5. 1. returns 105.
    proc maturity_value_loan_days { principal interest days} { [*  $principal  [+ 1. [* 1. $interest [/ $days 360. ]]]] }
    # Usage  maturity_value_loan_days 100. .05 360. returns 105.
    # ****** relative error in percent *****************************************
    #  error in percent is  < attested value>  over <calculated value>  times 100.  percent.
    #  for relative error without percent,  
    #  < attested value>  over <calculated value>  times 1.0
    #  for relative error without percent,  swap factor 100.0  to 1.0
    proc percent_errorx  {aa bb} {   expr { $aa > $bb ?   (($aa*1.)/$bb -1.)*100. : (($bb*1.)/$aa -1.)*100.}}
    # Effectively  percent_errorx is returning an absolute value of error in percent
    # Usage percent_errorx  1.2 1.0  returns 19.99 percent
    # Usage percent_errorx   1.0 1.2  returns 19.99 percent
    # Usage percent_errorx   1.5 1.0  returns  50.0 percent
    proc error_relative  {aa bb} {   expr { $aa > $bb ?   (($aa*1.)/$bb -1.)*1. : (($bb*1.)/$aa -1.)*1.}}
    proc error_relative  {aa bb} {   expr { $aa > $bb ?   (($aa*1.)/$bb -1.)*1. : (($bb*1.)/$aa -1.)*1.}}
    # Usage error_relative  1.2 1.0  returns 0.199
    # Usage error_relative  1.0 1.2  returns 0.199
    # Usage error_relative  1.5 1.0  returns 0.50
    puts " out  "


Bounds and Limits on the Collatz_Sequences help define the CS. trajectory and envelope


Recent results have indicated that there are bounds and limits on the Collatz_Sequences that might be useful in TCL expressions.Motta, Oliveira, and Cataban reported that the growth between successive odds is 3/4 . Hence, the reasonable expectation or guess that the sequence will reduce in time. A rigorous result from Krasikov and Lagarias was that the number of N's that inside the region 1 to N that will coalesce or reduce to 1 is greater than expr { $N**.84} . Wulf Rehder reported that the bound on the Collatz_Sequences return to the original entry integer was a constant. The Rehder_limit_collatz_sequences constant is expr { (log(3)/log(2))/(log(3)/log(2)+1.)} returns 0.61314719276545848 or 61.3 percent. The complement or < 1 - Rehder_limit> is 0.3868528072345415 or 38.6 percent . Meaning for long Collatz_Sequences and N>20 is that if one is at the Rehder_limit or return boundary of a long Collatz_Sequence, one can estimate the length of remaining steps of the tail. The Collatz_Sequence has 38.6 percent of tail left. It is curious that some of the TCLLIB Gauss_Legendre estimates for numbers of primes less than N are hovering over the lengths or step numbers of some Collatz_Sequences, N<50. Maybe numerical coincidence, but possibly these Gauss_Legendre procs could be hacked into predicting the length of some Collatz_Sequences. These results are not complete mathematical proofs of the Collatz Conjecture, but believe that the bounds will help characterize the envelope or trajectory of the longer Collatz_Sequences.


Lopsy posted that a number n has rough approximate ~log(n) Collatz steps to reach 1. Some Collatz_Sequences with 2 or more downward sequences and multiple breakpoints may be outliers to this ~log(n) formula. Solution for consecutive numbers with same Collatz length of steps starting at n, X = expr { log(n)* ( log(n))* ( log(log(n)))}, if consecutive numbers are present at number n. Have to check out ~log(n) Collatz steps. There are 7 steps for integer 10 whereasas numberPrimesLegendre 10 returns 7.677. There are 23 steps for integer 100 whereas numberPrimesLegendre 100 returns 27.73.


The Collatz_Sequence for 10 is < 10 5 16 8 4 2 1 > with 7 elements. By inspection, the Collatz_Sequence returns or drops below 10 between elements 3 and 4 or numbers 16 and 8 in the sequence. The Rehder_limit estimates the break point as expr { 7. * .613 } returns 4.291 , rounds to 4. The approximate number of terms or computer steps is 7. Using the Rehder_limit, Rehder_complement, and the expected tail of < 16 8 4 2 1 > , the approximate number of elements is estimated as expr { ( 4.* .613 ) / .386 } returns 6.352, a little off. The Collatz_Sequence for 27 has 112 elements. Sequence for 27 has two breakpoints on elements 96 and 104. At 96, breaks between 46 and 23. The Rehder_limit estimates the break point as expr { 112. * .613 } returns 68.656 , rounds to 69. llength sequence_27_breakpoint returns 96. Sequence for 27 has 16 elements in tail.



    # These statements should be pastable into the easy eye console.
    # *****  simple interest problems in TCL one liners procedures  *****
    # find simple interest amount from 3 entries as < principal  interest  years >
    proc simple_interest_amount   { principal interest  years } { expr {  ($principal*1.)*(1.+$years*$interest )}}
    # Usage simple_interest_amount  5000. .05 7. returns 6750.0
    # find simple interest principal  from 3 entries as < amount  interest  years >
    proc simple_interest_principal { amount  interest  years } { expr {  ($amount*1.)/(1.+$years*$interest )}}
    # Usage simple_interest_principal 6750.0 .05 7. returns 5000.0
    # find simple interest rate from 3 entries as < amount  principal  years >
    proc simple_interest_rate { amount  principal  years } { expr { ((($amount*1.)/$principal)-1.)/$years }}
    # Usage  simple_interest_rate 6750.0 5000. 7.   returns 0.05
    # find years of  simple interest from 3 entries as < amount  principal  interest >
    proc simple_interest_years { amount  principal  interest } { expr { ((($amount*1.)/$principal)-1.)/$interest }}
    # Usage simple_interest_years 6750.0 5000. .05  returns 7.0
    # ******  compound  interest problems in TCL one liners procedures ******
    # find compound interest amount from 4 entries as < principal  interest  years compounding_times_per_year >
    # cd is compounding times per year, usually 4 quarters or 12 months
    proc compound_interest_amount   { principal interest  years cd } { expr {  ($principal*1.)*((1.+( $interest /$cd))**($years*$cd))}}
    # Usage compound_interest_amount 5000 .05 7 12 retuRns 7090.180
    # find compound interest principal from 4 entries as < amount  interest  years cd >
    # cd is compounding times per year, usually 4 quarters or 12 months
    proc compound_interest_principal { amount  interest  years cd  } { expr { $amount*( 1. +(($interest*1.)/$cd ) )**(-1.*$cd*$years)}}
    # Usage compound_interest_principal 7090.180 0.05 7 12 returns  4999.997, rounds to 5000.
    # find interest in compound interest from 4 entries as < amount  principal  years cd >
    # cd is compounding times per year, usually 4 quarters or 12 months 
    proc compound_interest_interest { amount principal  years cd } { expr { $cd*((($amount*1.0)/$principal)**(1./($cd*$years))-1.)}}
    # Usage compound_interest_interest 7090.180 5000. 7 12 returns 0.049, rounds to 0.05
    # find years of  compound  interest from 4 entries as < amount  principal  interest  cd>
    proc compound_interest_years { amount principal interest cd  } { expr { (log10 (($amount*1.0)/$principal)) / ($cd*log10(1.+(($interest*1.)/$cd) ) ) }}
    # Usage compound_interest_years 7090.180 5000. 0.05 12 returns 6.99, rounds to 7 years
    # ******** continuous_compounding *******  based on exponential formulas and natural log.
    proc amount_continuous_compounding { principal interest years } { expr { $principal* exp ( $interest*$years*1. ) }}
    # Usage  amount_continuous_compounding  5000. 0.05 7  returns 7095.3377 
    proc principal_continuous_compounding { amount interest years } { expr { $amount * exp ( $interest*$years* -1.  ) }}
    #Usage  principal_continuous_compounding 7095.33 0.05 7. returns 4999.994, rounds to 5000.
    proc interest_continuous_compounding { amount principal years } { expr { (log ( ($amount*1.) /$principal  )) / ($years * log (exp(1.) ) )  }}
    # Usage  interest_continuous_compounding 7095.33 5000. 7 returns 0.04999, rounds to 0.05
    proc years_continuous_compounding { amount principal interest } { expr { (log ( ($amount*1.) /$principal  )) / ($interest * log (exp(1.) ) )  }}
     # Usage  years_continuous_compounding 7095.33 5000. 0.05 returns 6.999, rounds to 7 years

Draft Wikipedia article on One Liners Programs , TCL Tool Control Language


There is a gold mine of One Liners Programs and content in the Tool Control language TCL 8.6 core distribution, TCL manual pages, and TCLLIB library that can be adapted or recast into brief one liners programs. These one liners programs or procedures can be pasted into the TCL 8.6 console window for quick results, reference the TCL Wiki. Some one liners programs use the return statement, return $value, or return 1 to return the results to the program line. Although many TCL programmers just rely on the last computation being returned by the one liner procedure in the TCL console window. There is some room in the Wiki publications for programming style differences. But it is usually best to put usage, credits, or TCL documentation references for the one liners procedures on separate comment lines. The random procedures make use of the random function and do not return the same answer every time. Dependence on math operator notation, helper procedures, math check examples, and special library functions should be noted in the comment lines.


There are pros and cons to one liner programs in TCL. One may contrast the approach to one liners programs in problem solving versus the traditional procedural approach. There are better routines and methods in faster language constructs in the current TCL core distribution and TCLLIB. Working with recursion, primes, text search, and timing the procedures will quickly show the warts on the one liners programs. To gain speed and shorter computation times, one will generally have to access the TCL core distribution and TCLLIB. Since the TCL interpreter collapses the carriage returns, skips, blank lines, and dead space of traditional written procedures into a single line of machine code, is not every script a one liner program to the parser? As grandfather remarked, the gourmet omelet, beef mulligan stew, and farm buttermilk all go to the same place.


CREDITS ON ONE LINERS

WIKI BOOKS,  Programming_Examples pdf
WIKI BOOKS, Tcl_Programming_Introduction pdf
license https://creativecommons.org/licenses/by-sa/3.0/legalcode
creativecommons.org/licenses/by-sa/3.0/
en.wikibooks.org/wiki/Tcl_Programming_Introduction
Sample Math Programs, item 2, RS
TCLLIB math::mean is quicker by a third over some homebrew code.
Additional math functions
https://www.quora.com/What-are-the-most-useful-Swiss-army-knife-one-liners-on-Unix-That-is-what-is-your-favorite-one-liner-command-that-handles-a-task-usually-delegated-to-a-much-more-verbose-program-written-in-a-high-level-language
http://www.codecodex.com/wiki
SOURCE CODE SEARCH ENGINES, INCLUDE TCL????
Google Code Search
Koders
Krugle
Google Code Search
Koders
Krugle
Protecode
REFERENCES
http://www.codecodex.com/wiki
https://www.openhub.net/p?ref=homepage&query=tcl
https://en.wikipedia.org/wiki/Portal:Computer_programming
https://en.wikipedia.org/wiki/Portal:Free_and_open-source_software
https://en.wikipedia.org/wiki/Protecode
https://en.wikipedia.org/wiki/List_of_search_engines#Source_code
https://blog.robertelder.org/don-libes-expect-unix-automation-tool/

Question from member AV in Russia. So small basic interpreter... Who used small basic interpreters?


A. ## The original tiny basic was distributed in assembler code for the Altair and the 8080 circuit board. Essentially, tiny_basic is a historic legacy of mankind. The original Altair BASIC was about 150 dollars each. Some USA programmers in the 1970s gave away tiny_basic free to break the monopoly. tiny_basic was the first freeware or free software package widely given to the masses (circa 1970). In Russian terms, tiny_basic is the Battleship_Potemkin of computer geeks.


$$$$ The analogy of using tiny_basic to control the large TCL language is like sticking an Apple computer for the human operator in front of a Cray computer. The human mind probably can only understand and use a limited set of instructions, an interface in hardware or TCL? language as a limited set of instructions might be useful. After all, the human mind was designed to chase rabbits.


$$ mostly as a retiree, i am trying to freshen up tcl content on the tcl wiki, adding screenshoots and what meager code i can gin up. I have my limitations, but I am learning.


    # conventional expr math operation
    # factor 1. forces expression to floating point
    proc commission { commission sales }   {expr {1.* $commission  * $sales}}
    # Usage  commission   .10 100. returns 10.0
    # Using math operations notation for speed
    proc commission_2 { commission sales }   {*  1.  $commission  $sales }
    # Usage commission_2  .1 100   returns 10.0
    # *******************************   
    # commission_rate = commission over sales
    set commission_rate {expr {1.*$commission / $sales}}
    # conventional expr math operation
    proc commission_rate { commission sales } {expr {1.* $commission  / $sales}}
    #  using math operations notation
    proc commission_rate_2 { commission sales } [/ [* 1. $commission ]  $sales ]
    proc commission_rate_2  100. 10.
    proc commission_sales_2 { commission sales }   {expr {1.* $commission   *$sales}}

        # pretty print from autoindent and ased editor
        # Parametric Model Vaporware   V2
        # written on Windows 10 on TCL
        # working under TCL version 8.6
        # gold on  TCL Club, 4Oct2020
        # charting based on rotated ellipse by Gerard Sookahet
        # gold added push buttons calculatorand housekeeping 
        # using dummy calculations for parametric eq. calc.    
        package require Tk
        package require math::numtheory
        # added statements for TCLLIB library
        package require math::numtheory
        package require math::constants
        package require math::trig
        package require math
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
        # Tried to keep clean GS  code in upper section
        set tcl_precision 17
        proc pie {} {expr acos(-1)} ;# AMG
        # Section EllipseRotate.tcl 
        # Section proc EllipseRotate Author:      Gerard Sookahet
        # Date:        09 March 2019
        # Version:     0.1
        # Description: Simple graphical example of parametric equation of rotated ellipse
        #
        # xo,yo : center of the ellipse
        # angle : rotation angle from 0 to 7 with the scalebar
        # a : major radius
        # b : minor radius
        # t : parameter
        bind all <Escape> {exit}
        # Section proc Author:      Gerard Sookahet
        proc EllipseRotate {xo yo a b angle t} {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            set cosa [expr {cos($angle)}]
            set sina [expr {sin($angle)}]
            set cost [expr {cos($t)}]
            set sint [expr {sin($t)}]
            set x [expr {$xo + $a*$cosa*$cost - $b*$sina*$sint}]
            set y [expr {$yo + $a*$sina*$cost + $b*$cosa*$sint}]
            return [list $x $y]
        }
        proc EllipsePlot {w xo yo a b pi angle} {
            $w delete all
            lassign [EllipseRotate $xo $yo $a $b $angle 0] x2 y2
            for {set p 0} {$p <= 720} {incr p} {
                set t [expr {$pi*$p/360}]
                lassign [EllipseRotate $xo $yo $a $b $angle $t] x1 y1
                .c create line $x1 $y1 $x2 $y2 -fill blue -width 3
                set x2 $x1
                set y2 $y1
            }
        }
        # fallback settings
        #set width 600
        #set height 400
        set width 800
        set height 500
        set pi 3.1415926
        set xo [expr {$width/2}]
        set yo [expr {$height/2}]
        set a 200
        set b 100
        set angle [expr {$pi/6}]
        #pack [canvas .c -width $width -height $height -background black]
        #pack [scale .sc -from 0 -to 7 -length 240 -resolution .1 \
                -orient horiz -bd 1 -showvalue true -variable angle \
                -command {EllipsePlot .c $::xo $::yo $::a $::b $::pi}]
        package require Tk
        package require math::numtheory
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
        set tcl_precision 17
        frame .frame -relief flat -bg aquamarine4
        pack .frame -side top -fill y -anchor center
        set names {{} {parameter 1:} }
        lappend names {parameter 2:}
        lappend names {parameter 3:}
        lappend names {parameter 4:}
        lappend names {parameter 5:}
        lappend names {parameter 6:}
        lappend names {parameter 7:}
        lappend names {parameter 8:}
        foreach i {1 2 3 4 5 6 7 8} {
            label .frame.label$i -text [lindex $names $i] -anchor e
            entry .frame.entry$i -width 35 -textvariable side$i
            grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 }
        proc about {} {
            set msg "Calculator for Parametric Model Vaporware   V2
            from TCL ,
            # gold on  TCL Club, 10Jul2020 "
            tk_messageBox -title "About" -message $msg }
        proc self_help {} {
            set msg "Calculator for Parametric Model Vaporware V2
            from TCL ,
            # self help listing
            # 4 givens follow.
            1) parameter 1:
            2) parameter 1:
            3) parameter 1: 
            4) parameter 1:            
            # Recommended procedure is push testcase and fill frame,
            # change first three entries etc, push solve,
            # and then push report. Report allows copy and paste
            # from console to conventional texteditor. For testcases
            # testcase number is internal to the calculator and
            # will not be printed until the report button is pushed
            # for the current result numbers.
            # This posting, screenshots, and TCL source code is
            # copyrighted under the TCL/TK 8.6 license terms.
            # Editorial rights retained under the TCL/TK license terms
            # and will be defended as necessary in court.
            # gold on  TCL Club, 2Oct2020 "
            tk_messageBox -title "About" -message $msg }
        #  uses join, but computer time on some?
        proc mean_1  list {expr double([join $list +])/[llength $list]}
        # math operators exposed as commands, and the expand operator
        # math operators exposed as commands, and the expand operator
        proc mean_2  list {expr {[tcl::mathop::+ {*}$list]/double([llength $list])}}
        #  import the tcl::mathop operators
        proc mean_3 list {expr {[+ {*}$list]/double([llength $list])}}
        #  import the tcl::mathop operators from <Summing a list>
        proc table_calc {value} {
        # computer drag time sensitive on limit variable
        set limit 3
        # should apply to at my parametric model
        # a list of values (w_list) with cycle for.
        # In each step the code must set 3 coefficients (k1,k2,k3)
        # copy original format internet query
        set w_list [list  0.12   0.14   0.16   0.18   0.20 ];
        set k1_list [list {1.080} {1.101} {1.123} {1.144} {1.166}];
        set k2_list [list {1.116} {1.213} {1.260} {1.309} {1.360}];
        set k3_list [list {1.915} {2.157} {2.402} {2.649} {2.898}];
        # gold does not use braces around list elements, left as original 
        # copy of original format in internet query
        # setting table of dummy calculations
        # with data supplied in internet query
        puts "%|table| | printed in|TCL format |% "
        puts "&| session| proc &  mean value| elements in list  | comment, if any|& "
        for { set i 0 } { $i <= $limit }  { incr i } {
            # may leave redundant or fallback statements in draft program
            # set lister { 1 2 4 5 6 7 8 9 10 }
            set lister { 0.12   0.14   0.16   0.18   0.20 }
            lappend lister  [* $i [pie]]
            puts "&|$i | mean_1   [ mean_1  $lister ]| $lister |  $k1_list |   [ mean_1  $k1_list ]  |&"
            puts "&|$i | mean_2   [ mean_2  $lister ]| $lister |  $k2_list |   [ mean_2  $k2_list ]  |&"
            puts "&|$i | mean_3   [ mean_3  $lister ]| $lister |  $k2_list |   [ mean_3  $k3_list ]  |&"
        }}
        proc calculate {     } {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global testcase_number
            incr testcase_number
            set side1 [* $side1 1. ]
            set side2 [* $side2 1. ]
            set side3 [* $side3 1. ]
            set side4 [* $side4 1. ]
            set side5 [* $side5 1. ]
            set side6 [* $side6 1. ]
            set side7 [* $side7 1. ]
            set side8 [* $side8 1. ]
            set side5 1.
            set side6 1.
            set side7 1.
            set side8 1.
            table_calc 1
            set w_list [list  0.12   0.14   0.16   0.18   0.20 ] 
            set velocity_0 $side1
            set velocity_1 $side2
            set base_line [ expr { abs (  $side4 - $side3 )} ]
            set calculation_1 [ expr { .5 * ( $side1 + $side2 ) * 60. } ]
            set bisection_1 [ expr { .5 * $calculation_1 } ]
            set bisection_velocity_c [ expr {  ((($velocity_0)**2 +($velocity_1)**2)/2.)**.5 }]
            set bisection_time_c [ expr { $base_line * (  $velocity_0 -  $bisection_velocity_c  ) /  ( $velocity_0 -  $velocity_1  )  }]
            set side5 $bisection_velocity_c
            set side6 $bisection_1
            set side7 $bisection_time_c
            set side8 $calculation_1
            set side1 [* $side1 100. ]
            set side2 [* $side2 100. ]
            set side3 [* $side3 100. ]
            set side4 [* $side4 100. ]
            set side5 [* $side5 100. ]
            set side6 [* $side6 100. ]
            set side7 [* $side7 100. ]
            set side8 [* $side8 100. ]
        }
        proc fillup {aa bb cc dd ee ff gg hh} {
            .frame.entry1 insert 0 "$aa"
            .frame.entry2 insert 0 "$bb"
            .frame.entry3 insert 0 "$cc"
            .frame.entry4 insert 0 "$dd"
            .frame.entry5 insert 0 "$ee"
            .frame.entry6 insert 0 "$ff"
            .frame.entry7 insert 0 "$gg"
            .frame.entry8 insert 0 "$hh"
        }
        proc clearx {} {
            foreach i {1 2 3 4 5 6 7 8 } {
                .frame.entry$i delete 0 end } }
        proc reportx {} {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global testcase_number
            console show;
            console eval {.console config -bg palegreen}
            console eval {.console config -font {fixed 20 bold}}
            console eval {wm geometry . 40x20}
            console eval {wm title . " Parametric Model Vaporware  V2 Report , screen grab and paste from console 2 to texteditor"}
            console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}
            puts "%|table $testcase_number|printed in| tcl format|% "
            puts "&| quantity| value| comment, if any|& "
            puts "&| $testcase_number:|testcase_number | |&"
            puts "&| $side1 :|parameter 1: |   |&"
            puts "&| $side2 :|parameter 2: | |& "
            puts "&| $side3 :|parameter 3: | |& "
            puts "&| $side4 :|parameter 4: | |&"
            puts "&| $side5 :|parameter 5:| |  |&"
            puts "&| $side6 :|parameter 6:| |  |&"
            puts "&| $side7 :|parameter 7:| |  |&"
            puts "&| $side8 :|parameter 8:| |  |&"
            
        }
        frame .buttons -bg aquamarine4
        ::ttk::button .calculator -text "Solve" -command { calculate   }
        ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 1.080 1.101 1.123  1.144  1.116 1.0  1.0  1.0 }
        ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 1.116 1.213  1.260  1.309  1.360 1.0  1.0  1.0 }
        ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 1.915 2.157 2.402  2.649  2.649 1.0  1.0  1.00  }
        ::ttk::button .clearallx -text clear -command {clearx }
        ::ttk::button .about -text about -command {about}
        ::ttk::button .self_help -text self_help -command {self_help}
        ::ttk::button .console2 -text report -command { reportx }
        ::ttk::button .exit -text exit -command {exit}
        canvas .c -width $width -height $height -background black
        scale .sc -from 0 -to 7 -length 240 -resolution .1 \
                -orient horiz -bd 1 -showvalue true -variable angle \
                -command {puts " display scale $side1 $side2 $side3 $side4 [pie]"; EllipsePlot .c $side1 $side2 $side3 $side4 [pie]}
        pack .c .sc .calculator -in .buttons -side top -padx 10 -pady 5 
        pack  .clearallx .console2 .self_help .about .exit .test4 .test3 .test2   -side left -in .buttons
        grid .frame .buttons -sticky ns -pady {0 10}
        . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30
        wm title . " Parametric Model Vaporware V2"
        # gold on TCL Club, 8Jul2020
        # This posting, screenshots, and TCL source code is
        # copyrighted under the TCL/TK 8.6 license terms.
        # Editorial rights retained under the TCL/TK license terms
        # and will be defended as necessary in court.
        # end of file
       


Appendix: One Liner Procs for Modeling Planetary Distances using Titius-Bode Law and other power laws


     ;# for starting the adventure  to infinity and beyond.
     ;#  Titius-Bode set < Earth = 1 ... > as number assignment scheme for planets
     ;# The Asteriod Ceres is included on most number assignment schemes
     ;# Ceres represents the Asteriod belt between Mars and Jupiter.
     ;# The dwarf planet Pluto  is included on most number assignment schemes.
     proc titius_bode_law_1772  {aa } {expr { (4. + 3 * 2**$aa)*.1 } }  ;# ;# $nn=l for Earth,2,...
     ;# Other planet number schemes are for power laws are available here, < Mercury = 1 ...>
     ;# from Gaussin (1880) and Armellini (1921)
     proc gaussin_formula_1880  {nn} {expr {0.2099 * (1.7226 ** $nn)} } ;# $nn=l for Mercury,2,...9
     proc armellini_formula_1921  {nn} {expr {0.283 * (1.53 ** $nn)} }  ;# $nn=l for Mercury,2,...11
     ;# very interesting, Nicolini transformed planet number scheme in  Titius_Bode 
     ;# to < Mercury = 1 ...>, refer to Nicolini
     proc nicolini_formula_1957  {nn} {expr {0.4 + 0.075 * (2. ** $nn)} }  ;# $nn=l for Mercury,2,... 
     proc basano_hughes_formula_1979  {nn} {expr {0.285 * (1.523 ** $nn)} } ;# $nn=l for Mercury, 2,...
     ;# Sven-Ingmar Ragnarsson, 1994, modeled Jupiter and the outer planets to Uranus, separately. 
     ;# See the  Ragnarsson paper, setting these planet assignment numbers is tricky.
     ;# $nn=0 for Jupiter, 2 = Saturn, 3 = Uranus ....
     proc ragnarsson_formula_1979  {nn} {expr {5.203*(((5./2.)**(2./3.))**$nn) )} } ;# $nn=0 for Jupiter, 2 = Saturn,...
     proc list_integers { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  1.]};return $boo}  
     ;# usage, list_integers 1 10
     ;# set answer_list_integers = [list 1.0  1.0 2.0 2.0 3.0 3.0 4.0 4.0 5.0 5.0 6.0 6.0 7.0 7.0 8.0 8.0 9.0 9.0 10.0 10.0 ]
     proc list_titius_bode  { aa bb} { for {set i 1} {$i<=$bb} {incr i}    {lappend boo [* 1. $i ] [expr { (4. + 3. * 2**$i)*.1}]};if {$i > $bb} {return $boo}}
     ;# Usage   list_titius_bode 1 6
     ;# set answer [ list 1.0 1.0 2.0 1.6 3.0 2.8 4.0 5.2 5.0 10.0 6.0 19.6]
      proc list_gaussin_formula  { aa bb} { for {set ii 1} {$ii<=$bb} {incr ii} {lappend boo [* 1. $ii ] [expr {0.2099 * (1.7226 ** $ii)} ]};if {$ii > $bb} {return $boo}}
      ;# Usage   list_gaussin_formula 1 6
      ;# set answer_gaussin [ list 1.0 0.36  2.0 0.62  3.0 1.07  4.0 1.84  5.0 3.18  6.0 5.48 ]
      proc list_armellini_formula  { aa bb} { for {set ii 1} {$ii<=$bb} {incr ii}    {lappend boo [* 1. $ii ] [expr {0.283 * (1.53  ** $ii)}]};if {$ii > $bb} {return $boo}}
      ;# Usage  list_armellini_formula 1 7
      ;# set answer_armellini [  1.0 0.43 2.0 0.66 3.0 1.013 4.0 1.55 5.0 2.37 6.0 3.63  7.0 5.55 ]

  Console wrapper for solution proc
  ***************************
  ***************************
table 2 printed in tcl wiki format
quantity value value comment, if any
2:testcase_number
13.67 :initial length
1.0 :iteration :
1.0 :option switch mode, usually 1 , modes = 2, 3, 4:
1.0 :optional constant, nominal 1 ::
1. : experimental decay constant_K1 :
Note : experimental constant_k1 not used :
54.679999999999993 : Koch snowflake perimeter from iteration N :
80.916607288626935 : area initial triangle :
107.88880971816924 : area first iteration :
107.88880971816926 : Koch snowflake area from iteration N :
129.4665716618031 : limit to Koch snowflake area from infinite series :
table 3 printed in tcl wiki format
quantity value value comment, if any
3:testcase_number
4.5566666659999999 :initial length
2.0 :iteration :
1.0 :option switch mode, usually 1 , modes = 2, 3, 4:
1.0 :optional constant, nominal 1 ::
1. : experimental decay constant_K1 :
Note : experimental constant_k1 not used :
24.302222218666664 : Koch snowflake perimeter from iteration N :
8.9907341405499785 : area initial triangle :
11.987645520733304 : area first iteration :
13.319606134148117 : Koch snowflake area from iteration N :
14.385174624879966 : limit to Koch snowflake area from infinite series :
table 4 printed in tcl wiki format
quantity value value comment, if any
4:testcase_number
1.5188888 :initial length
3.0 :iteration :
3.0 :option switch mode, usually 1 , modes = 2, 3, 4:
1.0 :optional constant, nominal 1 ::
1. : experimental decay constant_K1 :
Note : experimental constant_k1 not used :
10.80098702222222 : Koch snowflake perimeter from iteration N :
0.99897034342930124 : area initial triangle :
1.3319604579057349 : area first iteration :
1.5457318894214702 : Koch snowflake area from iteration N :
1.598352549486882 : limit to Koch snowflake area from infinite series :
table 5 printed in tcl wiki format
quantity value value comment, if any
5:testcase_number
0.50629629600000003 :initial length
4.0 :iteration :
3.0 :option switch mode, usually 1 , modes = 2, 3, 4:
1.0 :optional constant, nominal 1 ::
1. : experimental decay constant_K1 :
Note : experimental constant_k1 not used :
4.8004389546666664 : Koch snowflake perimeter from iteration N :
0.11099671768713089 : area initial triangle :
0.14799562358284118 : area first iteration :
0.17499619688396309 : Koch snowflake area from iteration N :
0.17759474829940941 : limit to Koch snowflake area from infinite series :
table 7 printed in tcl wiki format
quantity value value comment, if any
7:testcase_number
0.16876543199999999 :initial length
5.0 :iteration :
1.0 :option switch mode, usually 1 , modes = 2, 3, 4:
1.0 :optional constant, nominal 1 ::
1. : experimental decay constant_K1 :
Note : experimental constant_k1 not used :
2.1335284242962951 : Koch snowflake perimeter from iteration N :
0.012332968631903429 : area initial triangle :
0.016443958175871239 : area first iteration :
0.019604426284356775 : Koch snowflake area from iteration N :
0.019732749811045485 : limit to Koch snowflake area from infinite series :

Under Titius_Bode , Wikipedia page.


Can someone show some sample Cerda calculations on say, Mars and Jupiter. ? What is parameter or function D, not obvious from text. I have programmed the Titius_Bode equation into a Tool Control language TCL program and very interested in programming the Cerda calculations also. Quote: In Tratado de Astronomía, Cerdà obtaines (sp) the planetary distances from the orbital periods by applying Kepler's third law, with an accuracy of 10−3 . Maybe there is a contact interested in working on this item? Thank you.


Taylor series for tangent


;# puts  taylor tangent series into pade tangent
;# of rational numbers ratio into horners form
;# num/denum=(1/45*$x**9 - 22*$x**7 + 3003*$x**5 - 105105*$x**3 + 765765*$x)/($x**8 - 308*$x**6 + 21021*$x**4 - 
360360*$x**2 + 765765)
;# num=1/45*(((($x**2 - 990)*$x**2 + 135135)*$x**2 - 4729725)*$x**2 + 34459425)*$x
;# denum=((($x**2 - 308)*$x**2 + 21021)*$x**2 - 360360)*$x**2 + 765765
symdiff {(1/45.*$x**9 - 22*$x**7 + 3003*$x**5 - 105105*$x**3 + 765765*$x)} x
((((((9 * pow($x, 8)) * (1 / 45.)) - ((7 * pow($x, 6)) * 22)) + ((5 * pow($x, 4)) * 3003)) - ((3 * pow($x, 2)) * 105105)) + 765765.0)
symdiff {($x**8 - 308*$x**6 + 21021*$x**4 - 360360*$x**2 + 765765)} x
((((8 * pow($x, 7)) - ((6 * pow($x, 5)) * 308)) + ((4 * pow($x, 3)) * 21021)) - ((2 * $x) * 360360))
       # Functional math system for integers from RS
        # Playing with recursion
        # Richard Suchenwirth 2004-10-24
        # two functions should be enough to derive all arithmetics
        proc func {name argl body} {proc $name $argl [list expr $body]}
        proc '  x    {incr x}
        proc = {m n} {string equal $m $n}
        func pred   n    {[pred2 $n 0]}
        func pred2 {n m} {[= [' $m] $n]? $m: [pred2 $n [' $m]]}
        proc = {m n} {string equal $m $n}
        proc test args {
            foreach {case expected} $args {
                catch {uplevel 1 $case} res
                if {$res != $expected} {error "$case->$res, expected $expected"}
            }
        }
        func + {m n} {[= $n 0]? $m: [+ [' $m] [pred $n]]}
        #-- the product
        func * {m n} {[= $n 0]? 0: [+ $m [* $m [pred $n]]]}
        #-- the difference (defined only for m >= n)
        func - {m n} {[= $n 0]? $m: [- [pred $m] [pred $n]]}
        #-- the inequality predicate <=
        func <= {m n} {[= $m 0]? 1: [= $n 0]? 0: [<= [pred $m] [pred $n]]}
        #-- leading to the strict inequality <
        func < {m n} {[= $m $n]? 0: [<= $m $n]}
        #-- Integer division goes like this:
        func / {m n} {[< $m $n]? 0: [' [/ [- $m $n] $n]]}
        #-- Integer division remainder (% in expr)
        func rem {m n} {[< $m $n]? $m: [rem [- $m $n] $n]}
        #-- Divisibility of a number n by a number m
        func | {m n} {[= $n 0]? 1: [< $n $m]? 0: [| $m [- $n $m]]}
        func prime   n    {[= $n 0]? 0: [= $n 1]? 0: [prime2 $n 2]}
        func prime2 {m n} {[= $m $n]? 1: [| $n $m]? 0: [prime2 $m [' $n]]}
        func gcd {m n} {[<= $n $m]?        [gcd $n $m]:
            [= [rem $n $m] 0]? $m:
            [gcd [rem $n $m] $m]}

* Pretty Print Version


            #  pretty print from autoindent and ased editor
            #  Collatz_Sequences (3*N+1) in Console Example Demo for TCL V2
            #  Console program example demo
            #  written on Windows 10 on  TCL
            #  working under TCL version 8.6
            #  gold on TCL Club , 11sep2021
            package require Tk
            package require math::numtheory
            package require math::constants
            package require math::trig
            package require math
            namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
            set tclprecision 17
            #  logic tests for even,  odd, positive, negative,  conditions of positive  numbers
            #  uses logic inside expr , if positive return 1, if not positive return 0
            proc isPositive x {return [ expr {$x>0}]}
            #  Richard Suchenwirth RS idea  in Math Sugar
            #  uses logic inside expr, if negative return 1, if not negative return 0
            proc isNegative  x { return [ expr {$x<0}]}
            #  Richard Suchenwirth RS idea from wiki: Math Sugar
            #  idea by Michael Barth
            #  No error traps or safety nets here for negative and real numbers.
            #  conditional proc  IsOdd,  if N odd, return 1, if N not odd, return 0.
            proc IsOdd { N }  { return [ expr {$N % 2} ] }
            #  Usage
            IsOdd 5  #  returns 1
            #  conditional proc IsEven,  if N even,  return 1. If N not even return 0.
            proc IsEven { N }  { return [ expr { ( $N + 1 ) % 2} ] }
            IsEven 4 #  returns 1
            # 
            #  Results: collatz_sequence
            # 
            #  Return the collatz_sequence from positive integer
            # 
            #  Arguments:
            #     number first value is number
            #     iteration second value is iteration
            # 
            # 
            #  Note: This program can easily generate an endless loop.
            #         iteration number is a stop or limit to iteration
            #  By custom, the end of collatz_sequence is 1 or start of repetition
            proc collatz_sequence {number iteration} {
                #  Rewritten by HE on TCL WIKI
                #  Check parameter
                if {!([string is wideinteger $number] && $number > 0)} {
                    error "Number '$number' is not positive integer!"
                }
                if {!([string is wideinteger $iteration] && $iteration > 0)} {
                    error "Iteration '$iteration' is not positiv integer!"
                }
                #  Initialisation
                set sequence [list $number]
                
                #  Interations
                for {set n 0} {$n <= $iteration} {incr n} {
                    if {$number == 1} {
                        return $sequence
                    }
                    if {$number % 2} {
                        #  Odd
                        set number [expr {(3 * $number) + 1}]
                    } else {
                        set number [expr {$number / 2}]
                    }
                    lappend sequence $number
                }
                #  After value reach 1 it is a endless sequence of 4 2 1 4 2 1 ...
                #  If we reach not 1 during the given ammount of iteration
                #  we raise an error to signal that number of iterations are to small
                #  or we reach the case all looking for.
                #  this error crops with large lists > 15 elements
                #  error "Number of iteration '$iteration' reached without getting 1!"
            }
            console show
            puts "  Console wrapper for solution proc"
            puts "  ***************************"
            puts "  ***************************"
            puts "collatz_sequence 31 130 collatz_sequence [collatz_sequence 31 130]"
            puts "collatz_sequence 11 15 collatz_sequence [collatz_sequence 11 15]"
            puts "collatz_sequence 10 15 collatz_sequence [collatz_sequence 10 15]"
            puts "collatz_sequence 9 20 collatz_sequence [collatz_sequence 9 20]"
            puts "collatz_sequence 8 15 collatz_sequence [collatz_sequence 8 15]"
            puts "collatz_sequence 7 20 collatz_sequence [collatz_sequence 7 20]"
            puts "collatz_sequence 6 15 collatz_sequence [collatz_sequence 6 15]"
            puts "collatz_sequence 5 15 collatz_sequence [collatz_sequence 5 15]"
            puts "collatz_sequence 4 15 collatz_sequence [collatz_sequence 4 15]"
            puts "collatz_sequence 3 15 collatz_sequence [collatz_sequence 3 15]"
            proc table_format_out  n {
                set sum 0
                #  initial  level
                set count 1
                puts "%| table|  | printed in|TCL format |% "
                puts "%| number | iteration |partial Collatz_Sequences  |comment, if any|% "
                #  adapted proc from <RS>
                #  printout in TCL WIKI format table
                for { set i 1 } { $i <= $n } { incr i } {
                    incr count
                    puts "&| $count | 120   | [ collatz_sequence $count 120 ]| |&"
                    incr sum $i
                }
                return $sum
            }
            table_format_out 31
            #  following dresses up console output to easy eye
            #  end of working deck
            #  add cosmetics below to bottom of file
            console eval {.console config -bg palegreen}
            console eval {.console config -font {fixed 20 bold}}
            console eval {wm geometry . 40x20}
            console eval {wm title . " Report for Collatz_Sequences (3*N+1) Calculator V2  "}
            console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}    

Trial Spreadsheet Calculations and Equations Section, 1/2/2024

Section 8 for Math Geeks
----
Sample math problems loaded into search engines.
-----
Collecting test problems for future calculator
----
Search engine math >>>> ( (88+98+91+92+91+ 93) / 5.) + 46.7) / 28.7
5.48083624 correct
----
Online conversion of average glucose to A1c:
https://professional.diabetes.org/dia...
Formula to convert estimated glucose to A1c: A1C(%) = (Estimated average glucose(mg/dL) + 46.7) / 28.7
----
Sample problem
----
Sum of 5 readings over a day.
Search engine math >>>>[88+98+91+92+91+ 93]
= 462 correct
sum over a day,
----
Search engine math >>>>
( 88+98+91+92+91+ 93 ) / 5
= 92.4 correct sum

----
Search engine math >>>> ( (88+98+91+92+91+ 93) / 5.) + 46.7) / 28.7
----
5.48083624 correct
*****
Note. This formula uses average BG readings from a home glucometer, not as accurate as lab blood test. But useful as a check on home glucometer results

----
Sample problem 2
----
Search engine math >>>>( (81+77.4+73.8 +81+73.8)) / 5.) + 46.7) / 28.7

4.32404181 correct
----
Results from 72 hour Sardine Challenge. Subject to interpretation
----
Kickstart Metabolism In 3 Days With Sardines
----
notes. 
(81+77.4+73.8 +81+73.8)/5=
----
((((81 + 77.4) + 73.8) + 81) + 73.8) / 5= 77.4 Avg BG
----
77.4 Avg BG ~ 4.2 = A1C
----
Note. Now that I am impressed, looks like the Sardine Team has cleared up a keto block within 3
days.
----
Note. Additional significant figures are used to check the TCL calculator, not to infer the accuracy of inputs and product reports. 
Meaning here, round to nearest tenth 0.1. 
----

Pseudocode and Equations Section

     #pseudocode can be developed from rules of thumb.
     #pseudocode: some problems can be solved by proportions (rule of three), to some order of magnitude
     #pseudocode: enter quantity1,  quantity2, quantity3 and expected output (quantity4) for testcases.
     #pseudocode: enter time in years, number of remaining items
     #pseudocode: output fraction of (remaining items) over (items at time zero)
     #pseudocode: ouput remaining items as fraction or percent
     #pseudocode: output fraction of (quantity4 ) over ( quantity1 at time zero)
     #pseudocode: output fraction of (quantity2) * (quantity3 ) over (quantity1 at time zero)
     #pseudocode: outputs should be in compatible units.
     #pseudocode: rules of thumb can be 3 to 15 percent off, partly since g..in g..out.
     #pseudocode: need test cases > small,medium, giant
     #pseudocode: need testcases within range of expected operation.
     #pseudocode: are there any cases too small or large to be solved?
     #; Terence Tao realized that the Collatz conjecture was similar to partial differential equations.
     #;  The Tao starting sample weighs  toward numbers that
     #; have a remainder of 1 after being divided by 3,
     #; and away from numbers that have a remainder of 2 after being divided by 3.
     #;  TCL pseudocode
     #;  remove all numbers divisible by 3 on a list of integers, 
     #;  find all numbers that have a remainder of 1, when divided by 3.


*** Subroutine for table in TCL Wiki format


Adapted proc from RS


        proc table_format_out  n {
            set sum 0
            # initial  level
            set count 0.0
            set glucose 100.
            puts "%| table|  | printed in|TCL format |% "
            puts "%| homa_IR_2 units | insulin units |glucose units  |comment, if any|% "
            # adapted proc from <RS>
            # printout in TCL WIKI format table
            for { set i 1 } { $i <= $n } { incr i } {
                set count [+ $count .1]
                set insulin $count
                set homa_IR_2 [ HOMA_IR2 $insulin $glucose  ]
                set insulin [ precisionx 3 $insulin ]
                set glocose [ precisionx 3 $glucose ]
                puts "&| [ precisionx 3  $homa_IR_2  ] |  $insulin  | $glucose | |&"
                incr sum $i
            }
            return $sum
        }
        table_format_out 90 
=====   
----
*** Subroutine for table in TCL Wiki format***
----
Adapted proc from [RS]
----
        proc table_format_out  n {
            set sum 0
            # initial  level
            set count 0.0
            set glucose 100.
            puts "%| table|  | printed in|TCL format |% "
            puts "%| homa_IR_2 units | insulin units |glucose units  |comment, if any|% "
            # adapted proc from <RS>
            # printout in TCL WIKI format table
            for { set i 1 } { $i <= $n } { incr i } {
                set count [+ $count .1]
                set insulin $count
                set homa_IR_2 [ HOMA_IR2 $insulin $glucose  ]
                set insulin [ precisionx 3 $insulin ]
                set glocose [ precisionx 3 $glucose ]
                puts "&| [ precisionx 3  $homa_IR_2  ] |  $insulin  | $glucose | |&"
                incr sum $i
            }
            return $sum
        }
        table_format_out 90 

=====


*** Proof Reading here


One Liner Programs Simple One Liner Procedure # One Liner Procedure proc greetings {} {

  puts "Hello World!"

} greetings Tcl This is a basic example of a one liner procedure in TCL. The procedure definition is done on a single line, and it simply prints out the message "Hello World!" when called. Random One Liner Procedure # One Liner Procedure proc random_number {} {

  expr {rand() * 100}

} puts random_number Tcl This one liner procedure generates a random number between 0 and 100 and prints it out. The random number is generated using the rand() function and multiplied by 100. Factorial One Liner Procedure # One Liner Procedure proc factorial n {

  expr {$n == 0 ? 1 : $n * [factorial [expr {$n - 1}]]}

} puts factorial 5 Tcl This one liner procedure calculates the factorial of a given number. It uses a recursive approach to calculate the factorial, starting with the given number and multiplying it by the factorial of the number minus 1 until it reaches 0. Prime Number One Liner Procedure # One Liner Procedure proc is_prime n {

  for {set i 2} {$i <= sqrt($n)} {incr i} {
    if {$n % $i == 0} {
      return 0
    }
  }
  return 1

} puts is_prime 17 Tcl This one liner procedure checks if a given number is prime. It uses a for loop to iterate from 2 to the square root of the given number, checking if the number is divisible by any of the iterated numbers. If it is divisible, it returns 0 (false), indicating that the number is not prime. If the loop completes without finding a divisor, it returns 1 (true), indicating that the number is prime. Text Search One Liner Procedure # One Liner Procedure proc search_text text needle {

  if {[string first $needle $text] != -1} {
    puts "Found $needle in $text"
  }

} search_text "Hello World!" "World" Tcl This one liner procedure searches for a specified substring (needle) within a given text. It uses the string first command to find the index of the first occurrence of the needle in the text. If the needle is found, it prints out a message indicating that it was found in the text. These one liner procedures demonstrate the simplicity and conciseness of TCL programming, while still being able to perform useful tasks.



gold 2/28/2024 Update. Received constructive feedback from offline and thanks to @ava____. & Under Test


@Ava____ >>> Memoization is a technique used in computer science to improve the efficiency of a program by storing the results of expensive function calls and returning the cached result when the same inputs occur again. This avoids redundant calculations and speeds up the program. To implement memoization in your TCL code, you can create a dictionary (hash table) to store the results. Implement memoization to avoid redundant calculations. For example, you can store the results of procedure calls in variables and reuse them when necessary.



Modify the dice_sides_N procedure to check if the result is already stored in the memoized dictionary. If it is, return the cached result; otherwise, calculate the result and store it in the dictionary:


proc dice_sides_N { dice_sides } {
    if {[dict exists $memoized $dice_sides]} {
        return [dict get $memoized $dice_sides]
    }
    set result [expr { 1 + int(rand()*$dice_sides)}]
    dict set memoized $dice_sides $result
    return $result
}

By using memoization, you can reduce the number of expensive calculations performed by your code, resulting in improved efficiency.


proc optimum_N { dice_sides } {
    if {[dict exists $memoized $dice_sides]} {
        return [dict get $memoized $dice_sides]
    }
    set result [expr { int(1.718281828 *$dice_sides) }]
    dict set memoized $dice_sides $result
    return $result
}


Test on printing list of dice throws


    Test on   printing list of dice throws
    # still checking here.
proc cast_dice {num_sides number_dice} {
    set num_throws 0
    set total 0
    while {$num_throws < $number_dice} {
        set total [expr $total + [expr { int($num_sides*rand())+1 } ]]
        incr num_throws
    }
    return $total
}
proc cast_dice_set {num_sides num_dice number_throws} {
    set all {}
    set num_throws 0
    while {$num_throws < $number_throws } {
        lappend all [cast_dice $num_sides $num_dice ]
        incr num_throws
    }
    return $all
}
puts " throws [ cast_dice_set 6 10 5 ] "

To use this program, simply call the cast_dice_set procedure with the desired number of sides and the number of dice in the set. The program will then throw the dice multiple times and return the results. Example usage: puts " throws throw_dice_set 6 10 "


set of 10 6-sided dice thrown 5 dimes. maximum number on a set = 60. still checking here. Minimum total for snake eyes = 6


    # Test on   printing list of dice throws
puts " throws [ cast_dice_set 6 10 5 ] " # 6 sides, 10 dice, 5 throws.
throws 27 35 40 36 30            #  6 sides, 10 dice, 5 throws.
puts " throws [ cast_dice_set 6 1 5 ] " # 6 sides, 1 die, 5 throws.
throws 6 4 1 4 6 
puts " throws [ cast_dice_set 6 2 5 ] "  # 6 sides, 2 dice, 5 throws.
throws 11 10 4 5 4 
puts " throws [ cast_dice_set 4 2 10 ] " 
# For 2 4-sided dice, max should be 8, 
# min should be 2,
# 10 throws are counted here
throws 6 5 6 6 8 2 3 7 6 6 
puts " throws [ cast_dice_set 2 6 15 ] "
throws 10 8 9 7 8 7 6 8 9 11 10 9 8 6 10 
puts " throws [ cast_dice_set 2 6 30 ] "
throws 9 7 9 7 10 10 10 10 7 10 8 10 10 11 9 8 9 8 10 8 10 10 8 9 9 9 11 9 10 11 

  # These are adapted from Brent Walsh's book and N.R. in C.
  # Make sure you call randomize first, then you can use the others ...
  # random_range 1 8
  # use brackets in expr
  proc randomize { seed } {
   global rand
   set rand(IA) 9301
   set rand(IC) 49297
   set rand(IM) 233280
   set rand(seed) $seed
  }
  proc random { } {
   global rand
   set rand(seed) [expr { ($rand(seed) * $rand(IA) + $rand(IC)) % $rand(IM)}]
   return [expr $rand(seed)/double($rand(IM))]
  }
  proc random_range { low up } {
   set delta [expr { $up - $low}]
   set comp [expr { double($low + ([random]*$delta))}]
   return $comp
  }
  randomize 12345678

puts " random number expr { int( [ random_range 1 6)} ] "



Abbreviation of decalogue *


Here is abbreviation of the 12 rules that define the syntax and semantics of the Tcl language:


1. Command Structure: A Tcl script is composed of one or more commands, separated by semicolons or newlines.


2. Command Evaluation: A command is processed in two steps – first, the Tcl interpreter divides the command into words and performs substitutions. Then, the first word is used to locate a routine to execute the command.


3. Word Separation: Words in a command are separated by white space.


4. Double Quotes: A word enclosed in double quotes allows for command, variable, and backslash substitutions.


5. Argument Expansion: Words starting with "{}" are treated as lists and added to the command being substituted.


6. Braces: Braces enclose a word without any substitutions or special interpretation of characters.


7. Command Substitution: Open brackets initiate command substitution, which replaces the brackets and all characters between them with the result of the script.


8. Variable Substitution: Dollar signs followed by a variable name replace the dollar sign and name with the variable's value.


9. Lists: Lists are sequences of elements separated by white space, with elements being any valid Tcl string.


10. Quoting: Backslashes, braces, and quotes can be used to prevent certain characters from being treated as command separators or substitutions.


11. Control Structures: Tcl provides control structures for conditional execution, loops, and error handling, such as if/else, for, while, and catch.


12. Error Handling: Built-in mechanisms like catch command and error return value help in handling and trapping errors in Tcl scripts.



Testing Mill's Constant


global theta
set theta 1.3063778838630806904686144926
proc mills_constant_tester {limit} { global theta;
expr {  int( [ expr {($theta**(3**$limit))} ] )}}
puts " mills_constant [ mills_constant_tester 1 ]      "
puts " mills_constant [ mills_constant_tester 2 ]     "
puts " mills_constant [ mills_constant_tester 3 ]   "
puts " mills_constant [ mills_constant_tester 4 ]   "
# mills_constant 2      
# mills_constant 11     
# mills_constant 1361   
# mills_constant 2521008886
# big numbers evaled and large significant figures in constant, results limited quickly in most setups. 

Condition that N>10, primes end in either 1,3,5,7 for base 10? In base 10, prime numbers end in either 1, 3, 7, or 9. The last digit of a prime number cannot be 0, 2, 4, 6, or 8 because those numbers are all divisible by 2. The last digit cannot be 5 because that would make the number divisible by 5. This leaves us with the last digits 1, 3, 7, and 9.



Probability on Dragon counting Game



Notes on 19Feb2024. Chinese excavations reveal a possible related divination system with space of 60 combinations. There are current Buddhist temple methods that picking a stick from 64 sticks or some other number. Popular Game of Pick up Sticks in West. In that case, the classic formula would be 1/64 for equal Hexagram probability and the probability space would 64 items. Bernoulli probability formula, P(Yang)= 1- P(Yin)


Notes on 13Feb2024.
4 yes-no binary sticks equals 2**4 combinations or 16 combinations. Probability of single cast 1/(2**4) or 1/16. Space = 16 items
5 yes-no binary sticks equals 2**5 combinations or 32 combinations. Probability of single cast 1/(2**5) or 1/32. Space = 32 items
6 yes-no binary sticks equals 2**6 combinations or 64 combinations. Probability of single cast 1/(2**6) or 1/64. Space = 64 items
7 yes-no binary sticks equals 2**7 combinations or 128 combinations. Probability of single cast 1/(2**7) or 1/128. Space = 128 items

 

The three most frequently occurring characters are:
吉 auspicious
无咎 no misfortune
凶 ominous

Thinking in Bullet Points
There are a total of 384 lines in the I Ching Oracle Book
There are roughly 100 lines with character "mistake", Chinese "Liu"
100/384 = 0.2604 probability of mistake Liu appearing
(384-100)= 284 number of lines without mistake Liu appearing
284/384= 0.7396 probability of mistake Liu not appearing
The probability of casting a line with the character "mistake" is 0.2604, roughly 1/4 or 0.25
The probability of casting a line with no character "mistake" is 0.7396, roughly 3/4 or 0.75
The probability of casting a line with or without character "mistake" is 0.2604 + 0.7396 = 1
One might conclude the I Ching Oracle Book is rigged not to cast a character "mistake".


SCRATCH SHEET on Dragon Counting Game


Note on Hand Calculations.


"Sweet winning number" in dragon counting game


Dragon counting Game from James Munro, mathematician at Oxford, UK


You're trapped in a dungeon with a 20-sided die, and a dragon demands that you pick a specific "sweet integer" number and roll a specific total to escape. For example, you choose the number 42, and if you succeed, you can leave the dungeon. If you fail, you'll be stuck with the dragon or face the dragon penalty box.


The rule of thumb for finding the maximum of a function involving natural logarithms and large values of N is to multiply N by a certain approximation. "Sweet winning number" as optimum number in dragon counting game is reported between N and 2N. As rule of thumb, a mathematician James Munro reported that Sweet Number rule as rounded {(e-1)*N)}. However, 1 plus phi conjugate or rounded {(1.6180339887 * N)} would give equivalent answer in small number field, less than 10. Correction here: the optimal number for the original 20-sided die problem is actually 35. This is slightly better than the quibble guess of 34. Mathematician has been fed to the dragon as punishment for this dragonish error. Not sure what significance that a "sweet number" means to the dragon. Maybe all numbers are sweet to the dragon at meal time , short of infinity.


Following par under math checks


The rule of thumb for finding the maximum of a function involving natural logarithms and large values of N is to multiply N by a certain approximation. This approximation is often used when dealing with functions that have a similar shape to the natural logarithm function. By multiplying N by the approximation, you can get a close estimate of the maximum of the function. This rule of thumb is particularly useful when working with large numbers, as it can save time and computational resources compared to finding the exact maximum. The specific approximation used can vary depending on the context and the function being analyzed. But the specific approximation or optimum generally involves multiplying N by a number expression using 2.718281828, which is the mathematical constant known as Euler's number. Note. This optimization function is sometimes called expm1(x) = exp(x) − 1. The expression exp(1) − 1 equals 1.71828182846.


Wordy text here. >>> So you're stuck in a dungeon with a 20-sided die and a dragon is keeping you in the dungeon. The dragon will only let you out if you can roll a particular total on the dice. Now you get to choose what the total is, so please could you choose me a number that's bigger than 20. - Yada-Yada >>> Uh all right, how about the Sweet Number as 42? 42, good number. Okay. so then your challenge is to roll the die and try to get 42. If you hit 42 you win, you get to leave the dungeon. Uh, if you don't hit 42 then you get kept in the dungeon with the dragon forever. Or start over again.... maybe in the dragon penalty box with very hungry dragon.


""" The rule of thumb for finding the maximum of a function involving natural logarithms and large values of N is to multiply N by a certain approximation."""" Note. "Sweet winning number" in dragon counting game is reported between N and 2N. As rule of thumb, a mathematician James Munro reported that Sweet number rule as rounded {(e-1)*N)}. However, 1 plus phi conjugate or rounded {(1.6180339887 * N)} would give equivalent answer in small number field, less than 10.


Correction here: the optimal number for the original 20-sided die problem is actually 35. This is slightly better than the quibble guess of 34. Mathematician has been fed to the dragon as punishment for this dragonish error.



PYK 2020-10-13: Hi gold, thank you for the cool pages you've contributed to this wiki. Your recent edit to upvar sugar was reverted by stevel, probably because it was so broad. My opinion: The concern is that if such broad reference sections proliferate, they lose the value they might have had. There is a natural hierarchy to content on the wiki. The page above upvar sugar is probably something like little language. A link to math sugar, for example, is a sibling to upvar sugar, so probably belongs on a higher page, and not on the upvar sugar page. For navigational purposes it's good enough to be able to browse through a "path" of links to some indirectly-related content, and to constrain the "reference" section only to directly-related pages, i.e. pages that might be considered siblings, children, or parents.

PYK 2020-10-21: In my recent edit to Playing Recursion V2 >> demo examples for one liner programs I removed the copyright notice. The entire content of this wiki is intended to be in th public domain, and thus copyright notices on individual pages are unneeded and could cause confusion. See Who owns the content on this Wiki.



gold 2020-10-20. How about me just loading the pix and charts alone at the bottom of these older works by other authors? That should not spoil the looks and "optics" of the older author pages. Since my moniker is on the pix, if readers want more info, refs, and the generating code, they may contact me. I do not have an ax to grind on copyright, other than no liability to me and TCL Wiki. I have some brain fog late at night, page was overwritten somehow. I have reloaded your edit 102 from the history, with omissions per request.


gold 2021-5-8. Removing copyright notices on <gold> authored pages as spare time allows. I do not have an ax to grind on copyright, other than no liability to me and TCL Wiki. The 2007 paper of David McFarland provided an excellent history of the quarter square multiplication algorithm in both the ancient and modern eras. The college institutes, textbooks, and computer companies in the USA that previously used the Babylonian mathematical ideas without credit may be glad to know that the Babylonian copyrights and patents expired about 4000 years ago.


gold 3/28/2024 Update. Received feedback from Maintainer ZXASX.


How destroy a redundant page? Thank you. Gold on Wiki. Shortening some titles and redundant pages, may take a while.


gold 3/28/2024 Thank you for your help on the login. Certainly, I will address your issues as best that I can. I guess that I could work on changes on outside editor, until more ready for publication. My Titles could be more brief. Gold on wiki.


ZXASX >>>> Edit the page and change the content to a single space.


asdfa >>> Recently able to delete a page by replacing its entire contents with a single space then saving it. This was the procedure used for the prior wiki. Is it still the right way to delete a page? Yeah, I know it's poorly documented, but it's what we (seem to) have


gold 3/28/2024: Note to clean up crew. Checking end of line issues here from laptop PC editor. If one sees a syntax error or brace typo error, go ahead and change. My eyes are bad on these tiny fonts. I am deleting some redundant files, now that I know how to close them.


Hidden Comments Section

If urgent matter, leave comment out in plain sight, here at bottom of page. As I am more likely to see it. If the issue is resolved, I may sweep under rug later.


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


PYK 2020-10-13: Hi gold, thank you for the cool pages you've contributed to this wiki. Your recent edit to upvar sugar was reverted by stevel, probably because it was so broad. My opinion: The concern is that if such broad reference sections proliferate, they lose the value they might have had. There is a natural hierarchy to content on the wiki. The page above upvar sugar is probably something like little language. A link to math sugar, for example, is a sibling to upvar sugar, so probably belongs on a higher page, and not on the upvar sugar page. For navigational purposes it's good enough to be able to browse through a "path" of links to some indirectly-related content, and to constrain the "reference" section only to directly-related pages, i.e. pages that might be considered siblings, children, or parents.

PYK 2020-10-21: In my recent edit to Playing Recursion V2 >> demo examples for one liner programs I removed the copyright notice. The entire content of this wiki is intended to be in the public domain, and thus copyright notices on individual pages are unneeded and could cause confusion. See Who owns the content on this Wiki.


gold 2020-10-20. How about me just loading the pix and charts alone at the bottom of these older works by other authors? That should not spoil the looks and "optics" of the older author pages. Since my moniker is on the pix, if readers want more info, refs, and the generating code, they may contact me. I do not have an ax to grind on copyright, other than no liability to me and TCL Wiki. I have some brain fog late at night, page was overwritten somehow. I have reloaded your edit 102 from the history, with omissions per request.


gold 2021-5-8.. Removing copyright notices on <gold> authored pages as spare time allows. I do not have an ax to grind on copyright, other than no liability to me and TCL Wiki. The 2007 paper of David McFarland provided an excellent history of the quarter square multiplication algorithm in both the ancient and modern eras. The college institutes, textbooks, and computer companies in the USA that previously used the Babylonian mathematical ideas without credit may be glad to know that the Babylonian copyrights and patents expired about 4000 years ago.


from rosetta code

set seed 675248

proc rnd {} {
    global seed
    set s [expr {$seed * $seed}]
    while {[string length $s] ne 12} {
        set s [string cat 0 $s]
    }
    set seed [string range $s 3 8]
    return $seed
}

for {set i 0} {$i < 5}  {incr i} {
    puts " neuwman midsquares method [rnd]"
}
 neuwman midsquares method 959861
 neuwman midsquares method 333139
 neuwman midsquares method 981593
 neuwman midsquares method 524817
 neuwman midsquares method 432883
# using mathop here in spots
#legendre_prime_density function might be  
proc  legendre_prime_density_approx {nn} {[/ 1. [- [log $nn 1.0866 ]] ] }
#   PI2(n) ~~ n/(log(n)*log(n)
# Under test, have to check syntax
# expr expression from Tcclib for legendre_tester  == expr {$limit / (log($limit) - 1.08366)}
# proc  legendre_tester {nn} { expr { 1./ ((log(n)*log(n)  )    }     }
# proc  legendre_tester {limit} {    }
proc  legendre_tester {limit} { $limit / (log($limit) - 1.08366) * (log($limit) - 1.08366)  }
puts " legendre_tester [ legendre_tester 100 ]      "
# proc  legendre_tester {limit} { $limit / (log($limit) - 1.08366)    }
proc legendre_tester {limit } { expr {$limit / ((log($limit) - 1.08366)*(log($limit) - 1.08366))}}
puts " legendre_tester [ legendre_tester 100 ]      "
puts " legendre_tester [ legendre_tester 1000 ]     "
puts " legendre_tester [ legendre_tester 10000 ]      "
#  legendre_tester 8.063843715007492 # approximation  #  legendre_tester 8.063843715007492 # approximation 
# legendre_tester 8.063843715007492      
# legendre_tester 29.48105748747322     
# legendre_tester 151.41665299041955         

Introduction


Here are some practical rules on curly braces and quotes in TCL. curly braces are essential to speed up math expressions in expr. Quotes are mainly used for exact text strings with some variable substitution. For example, puts " result value is expr { 1+3} " and print out is < result value is 4 >. If you are using the TCL console or easy eye calculator in the file system, paste in the TCL statement and this should show in big fonts on the console window. From the inside the double quotes the text is output exactly, whereas math expressions and $variables are evaluated inside the quotes. For practical use on the same line of code, quotes in TCL can printout exact text, text titles of variables, evaluated expressions, and $variables stored in programs.


Aside from expr, brackets are used with list command like set lister1 [ list dog cat lizard ] to store separate items in a list. Sometimes, curly braces are used with set command like set lister2 { list dog cat lizard } to store combined items in a string. The statement <set lister2 {" dog cat lizard" }; would store the three items in a single string representing one item in the list. Paste these expressions into the console and evaluate them . Here is a little console program: set lister1 { dog cat lizard } ; puts $lister1; set lister2 {" dog cat lizard" };puts $lister2;set lister3 {" dog cat” lizard };puts $lister3;set lister4 " dog cat lizard" ;$lister4; The TCL interpreter will see <set lister1 { dog cat lizard}> as three text variables stored in a single list. Quotes can act as a basket, mold, or glue to store text phrases inside the interpreter (in list structure). The TCL interpreter will see <set lister3 {" dog cat” lizard }> as two text variables of " dog cat” and “lizard” in a list. The TCL interpreter will see <set lister3 {" dog cat lizard"}> as one text variable in a list. The TCL interpreter will see <set lister4 " dog cat lizard"> as one text variable in a single string of text characters. The gist is that quotes and curly braces are used to tell the TCL interpreter how to evaluate the enclosed items either in parts or whole string, and much differently in some usage. Part of the confusion is that <dog cat lizard> can either be treated as either one item, two items, or three items in the interpreter, but the simple print out on the TCL console looks the same regardless. --- The key concept is how the items and information are stored and typed in the TCL interpreter either as a text string or list. The interpreter will usually try to type or tag the loaded data immediately. For an analogy in reading, the human brain loads the items above and tags them with associations, like fur for “dog cat”,scales for “lizard”, and teeth & claws for all. But the treatment of <dog cat lizard> in the mental processes generally depends on the use and association (symbols) for each individual item.


Conclusions


The key concept is how the items and information are stored and typed in the TCL interpreter either as a text string or list. The interpreter will usually try to type or tag the loaded data immediately. For an analogy in reading, the human brain loads the items above and tags them with associations, like fur for “dog cat”,scales for “lizard”, and teeth & claws for all. But the treatment of <dog cat lizard> in the mental processes generally depends on the use and association (symbols) for each individual item.