You will know better ways, but this "scribble" was a nice bit of
learning maths.
(setq max-lisp-eval-depth (expt 2 20))
(defun h-invnsq (this-n invnsq-sum)
(if (zerop this-n)
invnsq-sum
(h-invnsq (1- this-n) (+ invnsq-sum (/ 1e0 (expt this-n 2))))))
Thanks Axel
Regarding the second approach;
I have read
* Paul Graham's "On Lisp"
* Siebel's "Practical Common Lisp"
so have seen things like "gensym" and why has to be so.
Reality is, with very not-advanced lisp basics I seem to do well.
In my world of melting and shaping metal, there seems to be something
good about the working environment of equations and explanations in one document. It seems to facilitate a person developing their thoughts.
This seems to be the biggest issue - what the environment makes readily
and enjoyably achievable.
In recent years
* every beam calculation I want to do
(Euler-Bernoulli beam - derived 1750's; applied eg. Eiffel 1880's-ish)
which I do use frequently in my welding and engineering work
* a 1-D computer-numerical solution for heat-flow which proves a useful
"nutcracker" for considering what's going on where the issue is
conductive heat transfer
* in mineral processing (considering processing metal ores - tin,
copper, etc) I can run through calculations actually feeling very
happy
Mineral processing was last new application, a couple of months ago.
I'm surrounded by abandoned mines here - some of the iconic images of Cornwall. With for me the crucial thing being that tin-mining is
restarting here. There's also lithium here - efforts to work that.
None of these metals "self-extract" from the "run-of-mine" ore.
Hence mineral processing as an expertise.
Thing is, those happily-done calculations enabled me to see the twists-and-turns the author, with decades of experience of mineral processing, could throw at you to get you to think through the issue.
Layers deeper than the text alone could take you.
I had to visualise the minerals and mineral streams, then draw sketches
which were my "model",
then derive the maths (concurred with the
author's equations) - then write the elisp functions and get the
answers.
No immediate jobs so having to get back to welding - but could return to remind of the logical path which worked for me, in those files, whenever.
These were all "trivial" algebraic expressions, in computing terms.
I appreciate you showing me
where I could take my computing
if that juncture came.
Regards,
Rich Smith
Axel - I know that elisp doesn't optimise if an expressed recursive
function is tail-recursive.
A practical work-around is an alterative approach using the looping built-in's like "dotimes" (?) - where a recursive approach would have minimalistic beauty.
Regards, Rich S
It'll take 11 Tonnes load in gravity before bending.
The point - the path to the answer is part of the record, as well as the answer itself.--- Synchronet 3.21d-Linux NewsLink 1.2
And this is what makes the emacs environment so useful to me for what I
do.
I've preceded C-x C-e by C-u to put the answer into the buffer
C-u C-x C-e
Familiar day-to-day usage.
Thanks for showing me the more advanced programming posibilities.
check the elisp manual. it shows how to implement true tail recursion
in emacs.
(defun elisp-sum (args)
(elisp-sum-aux args 0))
(defun elisp-sum-aux (args res)
(if (null args)
res
(elisp-sum-aux (cdr args) (+ (car args) res))))
you can byte compile it. very simple.
Richard Smith <null@void.com> writes:
Thanks Axel
Regarding the second approach;
I have read
* Paul Graham's "On Lisp"
* Siebel's "Practical Common Lisp"
so have seen things like "gensym" and why has to be so.
Reality is, with very not-advanced lisp basics I seem to do well.
yeah me too :)
In my world of melting and shaping metal, there seems to be something
good about the working environment of equations and explanations in one
document. It seems to facilitate a person developing their thoughts.
I so agree! I thread and weld pipe for fire suppression systems. we use hydraulic calculations; if you can do this you are golden...
This seems to be the biggest issue - what the environment makes readily
and enjoyably achievable.
In recent years
* every beam calculation I want to do
(Euler-Bernoulli beam - derived 1750's; applied eg. Eiffel 1880's-ish)
which I do use frequently in my welding and engineering work
* a 1-D computer-numerical solution for heat-flow which proves a useful
"nutcracker" for considering what's going on where the issue is
conductive heat transfer
Oh yeah! another heat transfer variable :)
* in mineral processing (considering processing metal ores - tin,
copper, etc) I can run through calculations actually feeling very
happy
Mineral processing was last new application, a couple of months ago.
I'm surrounded by abandoned mines here - some of the iconic images of
Cornwall. With for me the crucial thing being that tin-mining is
restarting here. There's also lithium here - efforts to work that.
None of these metals "self-extract" from the "run-of-mine" ore.
Hence mineral processing as an expertise.
Thing is, those happily-done calculations enabled me to see the
twists-and-turns the author, with decades of experience of mineral
processing, could throw at you to get you to think through the issue.
Layers deeper than the text alone could take you.
I had to visualise the minerals and mineral streams, then draw sketches
which were my "model",
my boss still uses graphing paper and HGC3 (hydrolic calculator v3).
then derive the maths (concurred with the
author's equations) - then write the elisp functions and get the
answers.
No immediate jobs so having to get back to welding - but could return to
remind of the logical path which worked for me, in those files, whenever.
These were all "trivial" algebraic expressions, in computing terms.
I appreciate you showing me
where I could take my computing
if that juncture came.
Regards,
Rich Smith
Thank you!
Richard Smith <null@void.com> writes:
It'll take 11 Tonnes load in gravity before bending.
what guage steel you using at what incline? :)
The point - the path to the answer is part of the record, as well as the
answer itself.
And this is what makes the emacs environment so useful to me for what I
do.
I've preceded C-x C-e by C-u to put the answer into the buffer
C-u C-x C-e
Familiar day-to-day usage.
Thanks for showing me the more advanced programming posibilities.
steve g <sgonedes1977@gmail.com> writes:
... and then easily find out that it will enter the debugger for large
ARGS, say
(defun elisp-sum (number-sequence 1 10000000))
But with
(defmacro defun-tco (name args body)
"Wraps a 'named-let' around BODY to have a TCO of function NAME with ARGS."
(declare (indent defun))
(let ((bindings (gensym)))
(setq bindings (mapcar #'(lambda (arg) (list arg arg)) args))
`(defun ,name ,args
(named-let ,name ,bindings
,body))))
and
(defun-tco elisp-sum-aux (args res)
(if (null args)
res
(elisp-sum-aux (cdr args) (+ (car args) res))))
a
(defun elisp-sum (number-sequence 1 10000000))
will do.
Best regards
Axel--- Synchronet 3.21d-Linux NewsLink 1.2
steve g <sgonedes1977@gmail.com> writes:
check the elisp manual. it shows how to implement true tail recursion
in emacs.
(defun elisp-sum (args)
(elisp-sum-aux args 0))
(defun elisp-sum-aux (args res)
(if (null args)
res
(elisp-sum-aux (cdr args) (+ (car args) res))))
you can byte compile it. very simple.
... and then easily find out that it will enter the debugger for large
ARGS, say
(defun elisp-sum (number-sequence 1 10000000))
But with
(defmacro defun-tco (name args body)
"Wraps a 'named-let' around BODY to have a TCO of function NAME with ARGS."
(declare (indent defun))
(let ((bindings (gensym)))
(setq bindings (mapcar #'(lambda (arg) (list arg arg)) args))
`(defun ,name ,args
(named-let ,name ,bindings
,body))))
and
(defun-tco elisp-sum-aux (args res)
(if (null args)
res
(elisp-sum-aux (cdr args) (+ (car args) res))))
a
(defun elisp-sum (number-sequence 1 10000000))
will do.
Best regards
Axel
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 02:38:37 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,324 |