Recreational Coding - Procedural Math Library for Medley

18 views
Skip to first unread message

pixel...@gmail.com

unread,
May 26, 2026, 4:25:25 AM (6 days ago) May 26
to Medley Interlisp core
Good Morning,

I've had some time to hack on a personal Math library for Medley ...

Recently I've had some emergency eye stuff and I've not been able to drive for a week or so.
One eye had a hemorrhage and the other had odd vein growth at the back distorting my vision. The hemorrhage is clearning up well enough. The other eye required a needle and a trip out of town (fun fun fun!). The injection seems to be reducing the distortion so things are "looking" up.

Anyway I'm squinting like Popeye and hammering out code.
This is probably not guru level performant but after compiling it seems fairly OK.
I suppose a first foray into getting something *working* is better than nothing.
I've shifted towards the floating operations but I don't know if that's better than +/-TIMES etc.

I might dip into some of the stuff used in the MATMULT library.
I do need 4x4 transform matrices next ...
And things will really pick up when I get "coherent noise" working since that's a SUPER heavy lifter for various procedural effects.

I've not used AI *much*, mostly just to check a few of my implementations and search for possible oversights. I did use it for some of the more complex functions and checked the work with test cases in the EXEC. 

Here is the current library. (I've adopted the ! idiom from a few Lisp dialects as it's become more common even in CL projects.)

So I've got a pretty tough skin feel free to comment.
Since I'm around 50 functions in, probably best to get feedback now.

I'm not looking forward to writing my test package for this thing. I've been Exec testing as I enter them thank heavens for "INSPECT IT" on the last op.

PS
Larry, 
The Manager utility is very nice for larger libraries - thanks for mentioning it a while back.

Sincerely,
- Ryan

 



Paolo Amoroso

unread,
May 26, 2026, 4:29:10 AM (6 days ago) May 26
to pixel...@gmail.com, Medley Interlisp core
Do you experience any issues when renaming a function with MANAGER? I occasionally get an unreproducible error.


--
You received this message because you are subscribed to the Google Groups "Medley Interlisp core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispcore+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lispcore/0af5a21d-6c18-4529-902e-616e9774484an%40googlegroups.com.


--

pixel...@gmail.com

unread,
May 26, 2026, 4:29:22 AM (6 days ago) May 26
to Medley Interlisp core
Whoops, this is the link with the full repo and function listing...
(I'm blaming my mistakes on the squinting)

Ryan Burnside

unread,
May 26, 2026, 5:22:44 AM (6 days ago) May 26
to Paolo Amoroso, Medley Interlisp core
I've mostly been doing it manually. 
I'm still learning Manager's features.

The big win for me has been keeping all the functions in a file as clickable buttons in a menu among a few other niceties.

- Ryan

Matt Heffron

unread,
May 26, 2026, 8:36:46 PM (6 days ago) May 26
to pixel...@gmail.com, Medley Interlisp core

Ryan,

Looks OK, but you’ve mixed some CL functions that were imported into IL. (e.g. < , > ).

So, if the point was to do this all with Interlisp forms, you missed a little bit.

 

Now, my preferences…

If you’re willing to “bend” to include “some” CL features, I’d use a package that builds on the IL package (:USE “IL”) instead of name prefixes (V3F. RB.). You’d need to rename a few of the functions that would conflict with existing function names in IL:, e.g. NEGATE. (Though, not as many as I first thought!)

Likewise, the V3F name, itself, is not as descriptive as it could be.

 

Matt

pixel...@gmail.com

unread,
May 27, 2026, 12:19:04 PM (5 days ago) May 27
to Medley Interlisp core
I'll fix those, no problem.

I know there is currently a package fix in the works for CL so I've been avoiding CL namespaces.Maybe this would make a nice test case ...

Vectors tend to stack up so I want to keep the operation names shorter, but sure maybe I can call the data type itself VECTOR3D.

I also found out that there are about 3 competing notions of how a 4x4 identity matrix in graphics is laid out. I'll probably use one like in Origin (An engine component to the Colony Common Lisp game engine). My friend Pete Keller works on that and I might cheat off his math homework a bit. :)

I'll be doing plenty of renaming so we'll see if Paolo's reported bug in happens.

-Ryan

pixel...@gmail.com

unread,
May 28, 2026, 3:02:39 AM (4 days ago) May 28
to Medley Interlisp core
Sidetracked with getting the noise generators in. The idea is that you can use smooth transitions that are still random by adjusting the steps over the noise primitive.
Plenty of conversion from odd C tricks of yore relying on rollover of integers and magic prime numbers...

Perhaps a question for Nick (or anyone) ... are Interlisp floats and ints both 32 bit until promoted to non fixed ints?

Converting the C code below gets a bit sketchy when you've got unknown data sizes and huge integer support.

double IntegerNoise (int n)
{
  n = (n >> 13) ^ n;
  int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
  return 1.0 - ((double)nn / 1073741824.0);
}

I did get some "coherent noise" stuff working (see attached)
Essentially, it's a noise primitive where you adjust the step to form how much variation between steps.
This kind of thing can be used in many places where the randomness of random is too harsh.
Very natural special effects can come from it.
Screenshot_20260528_003519.png

Nick Briggs

unread,
May 28, 2026, 1:54:10 PM (4 days ago) May 28
to pixel...@gmail.com, Lisp Core
The underlying Medley floats and ints are both 32-bit. There are no double or int64 lisp opcodes. I'm not sure if you can suppress overflow detection on integer operations to avoid getting bignum conversions -- Larry might know the answer to that.

Larry Masinter

unread,
May 28, 2026, 3:23:16 PM (4 days ago) May 28
to Nick Briggs, pixel...@gmail.com, Lisp Core
There is no way that I know of to avoid overflow detection. The significant overhead of boxing and unboxing is avoided only with 17-bit smallp calculations. Even for intermediate results, which is even harder, you're kind of down to 8 bits at a time. (and I don't want to think to hard about what's going on with big/little endian).




--
You received this message because you are subscribed to the Google Groups "Medley Interlisp core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispcore+u...@googlegroups.com.

pixel...@gmail.com

unread,
May 28, 2026, 9:50:38 PM (3 days ago) May 28
to Medley Interlisp core
Thanks for the information all, I think I can make do adjusting the C algorithm.
For what I have in mind, that's just a one off edge case where overflow semantics matter.

- Ryan
Reply all
Reply to author
Forward
0 new messages