Version 9 of scratch

Updated 2024-03-14 14:17:05 by gold8888

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

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.

# list from copy of [Tcllib] deck on jdoodle.
puts " list of twin primes = [ listPrimePairs 3 100 2 ] "
list of twin primes = {3 5} {5 7} {11 13} {17 19} {29 31} {41 43} {59 61} {71 73}
======----
----
*** Testing Mill's Constant for Primes***
----

# Power formula produces a prime number from 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. ======s.


Note. Power formula produces a prime number from Mill's Constant. Big numbers are evaled here and large significant figures in constant. Results are limited quickly in most setups.


Note. 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.



Centigrade to Degrees Fahrenheit


    #   following one liners use math operator notation
    #   degrees Centigrade to degrees  Fahrenheit 
    proc  Fahrenheit cc {  [+ [* 1.8 $cc]  32. ]}
    #   Usage Fahrenheit 20 returns 68. degrees  Fahrenheit 
    #   degrees Fahrenheit to degrees  Centigrade 
    proc Centigrade ff  { [/ [-  $ff 32. ] 1.8 ]}
    #   Usage Centigrade 68 returns 20 degrees centigrade

Draft One Liners Spares