Browse Source

fix cmdtrace bug for expr mathfuncs

master
Julian Noble 3 weeks ago
parent
commit
9163daaf0a
  1. 46
      src/modules/punk/lib-999999.0a1.0.tm
  2. 5
      src/modules/punk/ns-999999.0a1.0.tm
  3. 46
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/lib-0.1.4.tm
  4. 5
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm
  5. 46
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/lib-0.1.4.tm
  6. 5
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm
  7. 46
      src/vfs/_vfscommon.vfs/modules/punk/lib-0.1.4.tm
  8. 5
      src/vfs/_vfscommon.vfs/modules/punk/ns-0.1.0.tm

46
src/modules/punk/lib-999999.0a1.0.tm

@ -3180,6 +3180,33 @@ namespace eval punk::lib {
#[para]Use expr's log10() function or tcl::mathfunc::log10 for base 10
expr {log($x)/log($b)}
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::factors
@cmd -name punk::lib::factors\
-summary\
"Sorted factors of positive integer x"\
-help\
"Return a sorted list of the positive factors of x where x > 0
For x = 0 we return only 0 and 1 as technically any number divides zero and there are an infinite number of factors.
(including zero itself in this context)*
This is a simple brute-force implementation that iterates all numbers below the square root of x to check the factors
Because the implementation is so simple - the performance is very reasonable for numbers below at least a few 10's of millions
See tcllib math::numtheory::factors for a more complex implementation - which seems to be slower for 'small' numbers
Comparisons were done with some numbers below 17 digits long
For seriously big numbers - this simple algorithm would no doubt be outperformed by more complex algorithms.
The numtheory library stores some data about primes etc with each call - so may become faster when being used on more numbers
but has the disadvantage of being slower for 'small' numbers and using more memory.
If the largest factor below x is needed - the greatestOddFactorBelow and GreatestFactorBelow functions are a faster way to get
there than computing the whole list, even for small values of x
* Taking x=0; Notion of x being divisible by integer y being: There exists an integer p such that x = py
In other mathematical contexts zero may be considered not to divide anything."
@values -min 1 -max 1
x -type integer
}]
}
proc factors {x} {
#*** !doctools
#[call [fun factors] [arg x]]
@ -3293,6 +3320,25 @@ namespace eval punk::lib {
}
return $r
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::gcd
@cmd -name punk::lib::gcd\
-summary\
"Gretest common divisor of m and n."\
-help\
"Return the greatest common divisor of m and n.
Straight from Lars Hellström's math::numtheory library in Tcllib
Graphical use:
An a by b rectangle can be covered with square tiles of side-length c,
only if c is a common divisor of a and b"
@values -min 2 -max 2
m -type integer
n -type integer
}]
}
proc gcd {n m} {
#*** !doctools
#[call [fun gcd] [arg n] [arg m]]

5
src/modules/punk/ns-999999.0a1.0.tm

@ -1989,7 +1989,7 @@ y" {return quirkykeyscript}
}
}
#2 arg form of nested switch - no problem with line-numbers for first 2 arms
proc test_switch4 {s} {
switch [string index $s 0] {
a {
@ -2023,6 +2023,7 @@ y" {return quirkykeyscript}
}
}
}
#3 arg form of nested switch - first 2 arms misreport line numbers
proc test_switch4b {s} {
switch -- [string index $s 0] {
a {
@ -2550,7 +2551,7 @@ y" {return quirkykeyscript}
}]} {
#eg cmd {tcl::mathfunc::sqrt 100}
puts "No line info for call: $callinfo"
set tinfo(disabled) false
set _cmdtrace_disabled false
return
}
switch -- $type {

46
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/lib-0.1.4.tm

@ -3180,6 +3180,33 @@ namespace eval punk::lib {
#[para]Use expr's log10() function or tcl::mathfunc::log10 for base 10
expr {log($x)/log($b)}
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::factors
@cmd -name punk::lib::factors\
-summary\
"Sorted factors of positive integer x"\
-help\
"Return a sorted list of the positive factors of x where x > 0
For x = 0 we return only 0 and 1 as technically any number divides zero and there are an infinite number of factors.
(including zero itself in this context)*
This is a simple brute-force implementation that iterates all numbers below the square root of x to check the factors
Because the implementation is so simple - the performance is very reasonable for numbers below at least a few 10's of millions
See tcllib math::numtheory::factors for a more complex implementation - which seems to be slower for 'small' numbers
Comparisons were done with some numbers below 17 digits long
For seriously big numbers - this simple algorithm would no doubt be outperformed by more complex algorithms.
The numtheory library stores some data about primes etc with each call - so may become faster when being used on more numbers
but has the disadvantage of being slower for 'small' numbers and using more memory.
If the largest factor below x is needed - the greatestOddFactorBelow and GreatestFactorBelow functions are a faster way to get
there than computing the whole list, even for small values of x
* Taking x=0; Notion of x being divisible by integer y being: There exists an integer p such that x = py
In other mathematical contexts zero may be considered not to divide anything."
@values -min 1 -max 1
x -type integer
}]
}
proc factors {x} {
#*** !doctools
#[call [fun factors] [arg x]]
@ -3293,6 +3320,25 @@ namespace eval punk::lib {
}
return $r
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::gcd
@cmd -name punk::lib::gcd\
-summary\
"Gretest common divisor of m and n."\
-help\
"Return the greatest common divisor of m and n.
Straight from Lars Hellström's math::numtheory library in Tcllib
Graphical use:
An a by b rectangle can be covered with square tiles of side-length c,
only if c is a common divisor of a and b"
@values -min 2 -max 2
m -type integer
n -type integer
}]
}
proc gcd {n m} {
#*** !doctools
#[call [fun gcd] [arg n] [arg m]]

5
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm

@ -1989,7 +1989,7 @@ y" {return quirkykeyscript}
}
}
#2 arg form of nested switch - no problem with line-numbers for first 2 arms
proc test_switch4 {s} {
switch [string index $s 0] {
a {
@ -2023,6 +2023,7 @@ y" {return quirkykeyscript}
}
}
}
#3 arg form of nested switch - first 2 arms misreport line numbers
proc test_switch4b {s} {
switch -- [string index $s 0] {
a {
@ -2550,7 +2551,7 @@ y" {return quirkykeyscript}
}]} {
#eg cmd {tcl::mathfunc::sqrt 100}
puts "No line info for call: $callinfo"
set tinfo(disabled) false
set _cmdtrace_disabled false
return
}
switch -- $type {

46
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/lib-0.1.4.tm

@ -3180,6 +3180,33 @@ namespace eval punk::lib {
#[para]Use expr's log10() function or tcl::mathfunc::log10 for base 10
expr {log($x)/log($b)}
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::factors
@cmd -name punk::lib::factors\
-summary\
"Sorted factors of positive integer x"\
-help\
"Return a sorted list of the positive factors of x where x > 0
For x = 0 we return only 0 and 1 as technically any number divides zero and there are an infinite number of factors.
(including zero itself in this context)*
This is a simple brute-force implementation that iterates all numbers below the square root of x to check the factors
Because the implementation is so simple - the performance is very reasonable for numbers below at least a few 10's of millions
See tcllib math::numtheory::factors for a more complex implementation - which seems to be slower for 'small' numbers
Comparisons were done with some numbers below 17 digits long
For seriously big numbers - this simple algorithm would no doubt be outperformed by more complex algorithms.
The numtheory library stores some data about primes etc with each call - so may become faster when being used on more numbers
but has the disadvantage of being slower for 'small' numbers and using more memory.
If the largest factor below x is needed - the greatestOddFactorBelow and GreatestFactorBelow functions are a faster way to get
there than computing the whole list, even for small values of x
* Taking x=0; Notion of x being divisible by integer y being: There exists an integer p such that x = py
In other mathematical contexts zero may be considered not to divide anything."
@values -min 1 -max 1
x -type integer
}]
}
proc factors {x} {
#*** !doctools
#[call [fun factors] [arg x]]
@ -3293,6 +3320,25 @@ namespace eval punk::lib {
}
return $r
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::gcd
@cmd -name punk::lib::gcd\
-summary\
"Gretest common divisor of m and n."\
-help\
"Return the greatest common divisor of m and n.
Straight from Lars Hellström's math::numtheory library in Tcllib
Graphical use:
An a by b rectangle can be covered with square tiles of side-length c,
only if c is a common divisor of a and b"
@values -min 2 -max 2
m -type integer
n -type integer
}]
}
proc gcd {n m} {
#*** !doctools
#[call [fun gcd] [arg n] [arg m]]

5
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm

@ -1989,7 +1989,7 @@ y" {return quirkykeyscript}
}
}
#2 arg form of nested switch - no problem with line-numbers for first 2 arms
proc test_switch4 {s} {
switch [string index $s 0] {
a {
@ -2023,6 +2023,7 @@ y" {return quirkykeyscript}
}
}
}
#3 arg form of nested switch - first 2 arms misreport line numbers
proc test_switch4b {s} {
switch -- [string index $s 0] {
a {
@ -2550,7 +2551,7 @@ y" {return quirkykeyscript}
}]} {
#eg cmd {tcl::mathfunc::sqrt 100}
puts "No line info for call: $callinfo"
set tinfo(disabled) false
set _cmdtrace_disabled false
return
}
switch -- $type {

46
src/vfs/_vfscommon.vfs/modules/punk/lib-0.1.4.tm

@ -3180,6 +3180,33 @@ namespace eval punk::lib {
#[para]Use expr's log10() function or tcl::mathfunc::log10 for base 10
expr {log($x)/log($b)}
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::factors
@cmd -name punk::lib::factors\
-summary\
"Sorted factors of positive integer x"\
-help\
"Return a sorted list of the positive factors of x where x > 0
For x = 0 we return only 0 and 1 as technically any number divides zero and there are an infinite number of factors.
(including zero itself in this context)*
This is a simple brute-force implementation that iterates all numbers below the square root of x to check the factors
Because the implementation is so simple - the performance is very reasonable for numbers below at least a few 10's of millions
See tcllib math::numtheory::factors for a more complex implementation - which seems to be slower for 'small' numbers
Comparisons were done with some numbers below 17 digits long
For seriously big numbers - this simple algorithm would no doubt be outperformed by more complex algorithms.
The numtheory library stores some data about primes etc with each call - so may become faster when being used on more numbers
but has the disadvantage of being slower for 'small' numbers and using more memory.
If the largest factor below x is needed - the greatestOddFactorBelow and GreatestFactorBelow functions are a faster way to get
there than computing the whole list, even for small values of x
* Taking x=0; Notion of x being divisible by integer y being: There exists an integer p such that x = py
In other mathematical contexts zero may be considered not to divide anything."
@values -min 1 -max 1
x -type integer
}]
}
proc factors {x} {
#*** !doctools
#[call [fun factors] [arg x]]
@ -3293,6 +3320,25 @@ namespace eval punk::lib {
}
return $r
}
namespace eval argdoc {
variable PUNKARGS
lappend PUNKARGS [list {
@id -id ::punk::lib::gcd
@cmd -name punk::lib::gcd\
-summary\
"Gretest common divisor of m and n."\
-help\
"Return the greatest common divisor of m and n.
Straight from Lars Hellström's math::numtheory library in Tcllib
Graphical use:
An a by b rectangle can be covered with square tiles of side-length c,
only if c is a common divisor of a and b"
@values -min 2 -max 2
m -type integer
n -type integer
}]
}
proc gcd {n m} {
#*** !doctools
#[call [fun gcd] [arg n] [arg m]]

5
src/vfs/_vfscommon.vfs/modules/punk/ns-0.1.0.tm

@ -1989,7 +1989,7 @@ y" {return quirkykeyscript}
}
}
#2 arg form of nested switch - no problem with line-numbers for first 2 arms
proc test_switch4 {s} {
switch [string index $s 0] {
a {
@ -2023,6 +2023,7 @@ y" {return quirkykeyscript}
}
}
}
#3 arg form of nested switch - first 2 arms misreport line numbers
proc test_switch4b {s} {
switch -- [string index $s 0] {
a {
@ -2550,7 +2551,7 @@ y" {return quirkykeyscript}
}]} {
#eg cmd {tcl::mathfunc::sqrt 100}
puts "No line info for call: $callinfo"
set tinfo(disabled) false
set _cmdtrace_disabled false
return
}
switch -- $type {

Loading…
Cancel
Save