Caching (memoization) in (Gauche / Lisp / Scheme) and Python

2022-09-19 Thread Hen Hanna
so... for a few days i've been revising this Code (in Gauche / Lisp / Scheme) to make it run faster.. and last night i could improve it enough to give me the result i wantedin 72 minutes or so (on my slow PC at home). ( Maybe... within a few months, i'll write the same

Count-Trailing-Zeros(x) --- Can I use Log(x) to see if X is equal to ( Integer * 10 ^ k) ???

2022-09-19 Thread Hen Hanna
Count how many zeros are at the end of your int: defend_zeros(num): s = str(num) return len(s) - len(s.rstrip("0")) print(end_zeros(10)) # == 1 print(end_zeros(101)) # == 0 print(end_zeros(245))

is [comprehension] the right word???

2023-02-20 Thread Hen Hanna
is [comprehension] the right word??? i swear i never heard the word before getting into Python a few years ago. What was it called in the Lisp (Scheme) world ok... in Common Lisp, (and MacLisp) it was Loop and Collect https://en.wikipedia.org/wiki/List_comprehension#Hi

why is a search thru a Tuple slower ? ---- (meaningless indentations)

2023-02-20 Thread Hen Hanna
is Comp.Lang.Python very active why is a linear search thru a Tuple slower (than thru a (corresponding) List ) ??? sometimes, i 'd like to put meaningless indentations like i do (twice) below ( how ca

Re: is [comprehension] the right word???

2023-02-20 Thread Hen Hanna
On Monday, February 20, 2023 at 5:45:39 PM UTC-8, Paul Rubin wrote: > Hen Hanna writes: > > is [comprehension] the right word??? > Yes, it comes from math, particularly set theory. An expression like > > { n | n:integer, n mod 2 = 0 } > > is called a set comprehen

Tuple Comprehension ???

2023-02-20 Thread Hen Hanna
For a while, i've been curious about a [Tuple Comprehension] So finally i tried it, and the result was a bit surprising... X= [ x for x in range(10) ] X= ( x for x in range(10) ) print(X) a= list(X) print(a) -- https://mail.python.org/mailman/listinfo/python-list

Re: Tuple Comprehension ???

2023-02-21 Thread Hen Hanna
On Monday, February 20, 2023 at 7:57:14 PM UTC-8, Michael Torrie wrote: > On 2/20/23 20:36, Hen Hanna wrote: > > For a while, i've been curious about a [Tuple Comprehension] > I've never heard of a "Tuple comprehension." No such thing exists as > far as I know.

Re: Tuple Comprehension ???

2023-02-21 Thread Hen Hanna
On Tuesday, February 21, 2023 at 9:33:29 AM UTC-8, Axy wrote: > On 21/02/2023 04:13, Hen Hanna wrote: > > > > (A) print( max( * LisX )) > > (B) print( sum( * LisX )) <--- Bad syntax !!! > > > > What's most surprising is (A) is ok, and (B)

Python + Vim editor

2023-02-21 Thread Hen Hanna
what editor do you (all) use to write Python code? (i use Vim) yesterday (?) i started noticing this with Bing search e.g. i type [synonymrich] whch gives several synonyms, and so (next) i try to replace [rich] by something like

Re: Tuple Comprehension ???

2023-02-21 Thread Hen Hanna
On Tuesday, February 21, 2023 at 10:39:54 AM UTC-8, Thomas Passin wrote: > On 2/21/2023 12:32 PM, Axy via Python-list wrote: > > On 21/02/2023 04:13, Hen Hanna wrote: > >> > >> (A) print( max( * LisX )) > >> (B) print

Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
> py bug.py Traceback (most recent call last): File "C:\Usenet\bug.py", line 5, in print( a + 12 ) TypeError: can only concatenate str (not "int") to str Why doesn't Python (error msg) do the obvious thing and tell me WHA

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 2:32:57 AM UTC-8, Anton Shepelev wrote: > Hello, all. > > Does Python have an instrospection facility that can > determine to which outer variable a function argument is > bound, e.g.: > > v1 = 5; > v2 = 5; do some Python coders like to end lines with

Re: is [comprehension] the right word???

2023-02-22 Thread Hen Hanna
On Monday, February 20, 2023 at 5:45:39 PM UTC-8, Paul Rubin wrote: > Hen Hanna writes: > > is [comprehension] the right word??? > Yes, it comes from math, particularly set theory. An expression like > > { n | n:integer, n mod 2 = 0 } > > is called a set comprehen

it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-22 Thread Hen Hanna
it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and i'd get [Segmentation Fault] (core dumped) [Bus Error] (core dumped) [access violation] (core dumped)

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: > > py bug.py > Traceback (most recent call last): > File "C:\Usenet\bug.py", line 5, in > print( a + 12 ) > TypeError: can only concatenate str (not "int") to str > > >

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote: > On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: > > > py bug.py > > Traceback (most recent call last): > > File "C:\Usenet\bug.py", line 5, in > >

Re: semi colonic

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 6:21:13 PM UTC-8, Rob Cliffe wrote: > On 23/02/2023 02:04, Thomas Passin wrote: > > On 2/22/2023 7:58 PM, avi.e...@gmail.com wrote: > >> > >> > >> So can anyone point to places in Python where a semicolon is part of > >> a best > >> or even good way to do an

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Hen Hanna
On Wednesday, February 22, 2023 at 11:57:45 PM UTC-8, Barry wrote: > > On 23 Feb 2023, at 01:39, Hen Hanna wrote: > > > > On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote: > >> On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Han

Error-Msg Jeannie's charming, teasing ways

2023-02-23 Thread Hen Hanna
Python's Error-Msg genie (Jeannie) is cute and fickle... She sometimes teases me by not telling me what the VALUE of the "int" is ( "That's for me to know, and for you to find out!" ) as in: TypeError: can only concatenate str (not "int

putting JUNK at the end of a [.py] file

2023-02-23 Thread Hen Hanna
in a LaTeX file, after the (1st) \end{document} line, i can put any random Junk i want(afterwards) until the end of the file. Is there a similar Method for a.py file ? Since i know of no such trick, i sometimes put this (below) at the end of a .py file.

Re: putting JUNK at the end of a [.py] file

2023-02-24 Thread Hen Hanna
On Thursday, February 23, 2023 at 9:17:05 PM UTC-8, Thomas Passin wrote: > On 2/23/2023 7:21 PM, Hen Hanna wrote: > > > > in a LaTeX file, after the (1st) \end{document} line, > > i can put any random Junk i want (afterwards) until the end of the file. > > > &g

Find 6-letter words that are hidden (embedded) within

2023-02-24 Thread Hen Hanna
i just wrote a program, which... within[FunFunPython] finds: (funny,futon,python) ( 5- and 6- letter words ) (my program uses a Trie, but is pretty simple) Maybe someone would show me how it

Re: Find 6-letter words that are hidden (embedded) within

2023-02-24 Thread Hen Hanna
On Friday, February 24, 2023 at 10:34:31 AM UTC-8, Hen Hanna wrote: > i just wrote a program, which... >within [FunFunPython] >finds: (funny, futon, python) > >( 5- and 6- letter words ) > > > (my pro

TypeError: can only concatenate str (not "int") to str

2023-02-24 Thread Hen Hanna
TypeError: can only concatenate str (not "int") to str thanks for the comments, --- esp. 2 or 3 (?) ppl who directly addressed it or commented on it. py and pypy don't tell me what the (offending) int is (even tho' it'd be easy to s

Re: Find 6-letter words that are hidden (embedded) within

2023-02-24 Thread Hen Hanna
On Friday, February 24, 2023 at 1:18:28 PM UTC-8, David Raymond wrote: > > Find 6-letter words that are hidden (embedded) within each row of letters. > > The letters are in the correct order. > > > > 1. JSOYOMFUBELR > > 2. SCDUARWDRLYE > > 3. DASNAGEFERTY > > 4. CLULOOTSCEHN > > 5. USENEARSE

Re: TypeError: can only concatenate str (not "int") to str

2023-02-25 Thread Hen Hanna
-8, dn wrote: > On 25/02/2023 09.36, Hen Hanna wrote: > > TypeError: can only concatenate str (not "int") to str > > > > thanks for the comments, --- esp. 2 or 3 (?) ppl who directly addressed it > > or commented on it. > If you haven't already, please

unpack, pack

2023-02-25 Thread Hen Hanna
when i unpack the string (or Seed)USENEARSEYNE , i getwords like Sense, Sears, , Snare, Unary, (sarsen, seesee, senary, serene, unease, uneasy, usneae, usneas) (sensyne) How would i approach the PACKING function ? e.g. ... i want to fi

Re: TypeError: can only concatenate str (not "int") to str

2023-02-25 Thread Hen Hanna
On Saturday, February 25, 2023 at 4:54:36 PM UTC-8, Greg Ewing wrote: > On 26/02/23 10:53 am, Paul Rubin wrote: > > I'm not on either list but the purpose of the tutor list is to shunt > > beginner questions away from the main list. > There's a fundamental problem with tutor lists.

Re: TypeError: can only concatenate str (not "int") to str

2023-02-25 Thread Hen Hanna
On Saturday, February 25, 2023 at 1:54:14 PM UTC-8, Paul Rubinwrote: > Hen Hanna writes: > > is this guy (dn) always this rude??? is he even more rude on this > > Python-Tutor list ? > I'm not on either list but the purpose of the tutor list is to shunt > be

'dn' saying "Welcome (to the list)"

2023-02-25 Thread Hen Hanna
On Thursday, March 4, 2021 dn wrote: > Hi, and welcome to the list. note that this is the very same rude guy ('dn') who is apparently the rudest of them all. note that this is the very same rude guy ('dn') who wants to shunt me away to the TUTOR list. --- i guess

creepy email... Subj: Just to you.

2023-02-25 Thread Hen Hanna
i received thiscreepy email... Subj: Just to you. >>>Just to you as I see little further reason to help you ... >>>You have not taken hints that bashing the language as not doing what you >>> expect is not the way to get help so I leave you to others. i'll che

Re: 'dn' saying "Welcome (to the list)"

2023-02-26 Thread Hen Hanna
On Saturday, February 25, 2023 at 9:52:35 PM UTC-8, Chris Angelico wrote: > On Sun, 26 Feb 2023 at 16:23, Hen Hanna wrote: > > > > > > On Thursday, March 4, 2021 dn wrote: > > > Hi, and welcome to the list. > > > > > > note that this is the

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-26 Thread Hen Hanna
On Wednesday, February 22, 2023 at 10:38:00 PM UTC-8, Greg Ewing wrote: > On 23/02/23 9:37 am, Hen Hanna wrote: > > for the first several weeks... whenever i used Python... all i could think > > ofwas this is really Lisp (inside) with a thin veil of > &g

one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-26 Thread Hen Hanna
def Lisprint(x): print( ' (' + ', '.join(x) + ')' , '\n') a=' a b c ? def f x if zero? x 0 1 ' a += ' A B C ! just an example ' x= a.split() print(x) Lisprint(x) ['a', 'b', 'c', '?', 'def', 'f', 'x', 'if', 'zero?', 'x', '0', '1', 'A', 'B', 'C', '!', 'just', 'an', 'example'] (a, b,

Re: one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-26 Thread Hen Hanna
On Saturday, February 25, 2023 at 11:45:12 PM UTC-8, Hen Hanna wrote: > def Lisprint(x): print( ' (' + ', '.join(x) + ')' , '\n') > > a= ' a b c ? def f x if zero? x 0 1 ' > a += ' A B C ! just an example ' > x= a.spli

Vim (To move text-Lines between files) ___ :ab wt w! ~/temp.vi ___ :ab rt r ~/temp.vi

2023-02-26 Thread Hen Hanna
within Vim, do :smile ___ To move text-Lines between files --- i do this (below) Maybe there's a better (or more standard) way, but i've been doing this for 30+ years, so i'll prob. keep doing it. i have these in my .vimrc file.

Re-indenting Python code in Vim

2023-02-26 Thread Hen Hanna
Re-indenting Lisp code is =% and it works really well ! (define (foo x) (dotimes (i 100) (bar bar x))) --- it doesn't work as well for Python code. (doing 5==

Re: TypeError: can only concatenate str (not "int") to str

2023-02-26 Thread Hen Hanna
On Sunday, February 26, 2023 at 6:41:01 AM UTC-8, Thomas Passin wrote: > On 2/25/2023 8:12 PM, Hen Hanna wrote: > > 2. the rude guy ('dn') hasn't offered a single word of comment that's > > directly relevant to it. > > > but he did offer

Re: Python 3.10 Fizzbuzz

2023-02-26 Thread Hen Hanna
On Monday, August 29, 2022 at 7:18:22 PM UTC-7, Paul Rubin wrote: > Just because. > > from math import gcd > def fizz(n: int) -> str: >match gcd(n, 15): > case 3: return "Fizz" > case 5: return "Buzz" > case 15: return "FizzBuzz" >

Rob Cliffe should stop sending me rude email messages.

2023-02-26 Thread Hen Hanna
Rob Cliffe should stop sending me rude email messages. At the very least, Rob Cliffe should stop sending me ANY email messages, if he doesn't intend to an email i've sent him. -- https://mail.python.org/mailman/listinfo/python-list

Re: Vim (To move text-Lines between files) ___ :ab wt w! ~/temp.vi ___ :ab rt r ~/temp.vi

2023-02-26 Thread Hen Hanna
On Sunday, February 26, 2023 at 10:28:41 AM UTC-8, rbowman wrote: > On Sun, 26 Feb 2023 09:17:46 -0800 (PST), Hen Hanna wrote: > > > > To move text-Lines between files --- i do this (below) Maybe > > there's a better (or more standard) way, but i've been do

Re: Rob Cliffe should stop sending me rude email messages.

2023-02-26 Thread Hen Hanna
didn't get through, apparently) were among the few that were relevant. On Sunday, February 26, 2023 at 10:10:09 AM UTC-8, Hen Hanna wrote: > Rob Cliffe should stop sending me rude email messages. > > > At the very least, Rob Cliffe should s