More shaming of Python programmers

30 views
Skip to first unread message

The Beez

unread,
Jan 24, 2024, 7:23:54 AMJan 24
to 4tH-compiler
I don't even understand why these guys are calling themselves programmers:

Ok, the thing is - he needs a function that rounds an uneven number to the most even number. His version is:
: makeEven dup 2 mod 1 = if 1+ then ; 

Believe me - Python it is even wordier. It takes several lines. Now me:
: make_even 1+ 1 invert and ; 

This reduces the Python version to this:

def make_even(num): return(num+1 & (~1))

Just a "return". In uBasic this would be a oneliner:

_MakeEven Param (1) : Return (AND((a@+1), NOT(1)))

It's also 50% faster (in 4tH). And this kind of people want to educate other programmers??

Hans Bezemer

David Meyer

unread,
Jan 24, 2024, 8:33:29 PMJan 24
to 4th-co...@googlegroups.com
I've only dabbled with Python, but I am ashamed I didn't know a modulo and a conditional could be replaced with two bitwise operators. ;)

Jan 24, 2024 21:24:02 The Beez <the.bee...@gmail.com>:

--
You received this message because you are subscribed to the Google Groups "4tH-compiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 4th-compiler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/4th-compiler/0664f2ba-acb9-471e-9206-01ea56a3cd22n%40googlegroups.com.

--
David Meyer
Takarazuka, Japan
pa...@sdf.org
Reply all
Reply to author
Forward
0 new messages