Thanks!
I haven't used this macro in a billion years and wrote it as a comfort thingie
for the first 100 project Euler problems.
This thread got me to start thinking about how to memoize "smarter" and having
a macro that allows you to trade a bit of speed for being able to specifically
To answer my own question, I've now got a glimmer as to how to do most of
this, using syntax-case and quasi-syntax, as described in
https://www.gnu.org/software/guile/manual/html_node/Syntax-Case.html#Syntax-Case
with the display-compile-timestamp example, and then cleverly reworking
that.
Hi Taylan,
Our emails are crossing in the ether...
On Sat, Jan 11, 2020 at 9:21 PM Taylan Kammer
wrote:
>
> It might be possible to create a sort of "compile-time memoization"
Yes, that's what I'm looking for...
So the following:
>
> (display (f-memo 42))
> (display (f-memo 66))
>
Thank you Taylan!
So let me seize on this statement:
On Sat, Jan 11, 2020 at 3:56 PM Taylan Kammer
wrote:
> On 11.01.2020 19:52, Linas Vepstas wrote:
>
> When you compile the code, all that actually ends up in the program is
> "(display ...)" with no trace of the original "(symbol-syntax?
On 12.01.2020 03:12, Linas Vepstas wrote:
> To answer my own question, it appears doable with a very simply macro, then:
>
> (define (bar x)
>(format #t "Called bar with ~A\n" x)
>(+ x 1))
>
> (define (memoize FUNC)
> "
> memoize a function FUNC which takes a single int as argument
> "
I can add a contribution! The good thing about memoize is it's simple to
create. You forgot a catch however: if the memoized return-val is #f then
your memoizer https://hg.sr.ht/~bjoli/misc/browse/default/memoize.scm will
not recognise that #f is a valid cached return-val and will call the lambda
Thanks Taylan, gmail is on the fritz lately and doesn't show replies until
after I post; let me read what you wrote and ponder. ~~~
On Sat, Jan 11, 2020 at 3:56 PM Taylan Kammer
wrote:
> On 11.01.2020 19:52, Linas Vepstas wrote:
> > Or, thinking aloud a bit: boxes and symbols
> >
> > So,
To answer my own question, it appears doable with a very simply macro, then:
(define (bar x)
(format #t "Called bar with ~A\n" x)
(+ x 1))
(define (memoize FUNC)
"
memoize a function FUNC which takes a single int as argument
"
(define cache (make-hash-table))
(define (int-hash INT
On 11.01.2020 19:52, Linas Vepstas wrote:
> Or, thinking aloud a bit: boxes and symbols
>
> So, for example, if I was able to tell apart calls (f 42) from calls (f x)
> where x is a "symbol" (or "variable", *see below*) referencing an integer,
> then, for the former case, I could create a new
Or, thinking aloud a bit: boxes and symbols
So, for example, if I was able to tell apart calls (f 42) from calls (f x)
where x is a "symbol" (or "variable", *see below*) referencing an integer,
then, for the former case, I could create a new symbol (in guile) and
attach it to a box, fill that
Hmm Thanks. Perhaps I should have been more clear. I'm talking about a
handful of values that behave like constants, and NOT about memoization.
So here's a bit more detail. The only thing the C++ code is doing is
stuffing the values into a giant hash table... in C++. So its already very
fast.
I have a macro called lambda/memo and define/memo for these situations:
https://hg.sr.ht/~bjoli/misc/browse/default/memoize.scm
If the function gets called with a gazillion different arguments the
memoizatiin hash gets large, and there are no mechanisms to stop that from
happening. It also
On 1/10/20 2:36 PM, Linas Vepstas wrote:
So, I've got lots of C code wrapped up in guile, and I'd like to declare
many of these functions to be pure functions, side-effect-free, thus
hopefully garnering some optimizations. Is this possible? How would I do
it? A cursory google-search reveals no
Hello Linas,
On 1/10/20 11:36 PM, Linas Vepstas wrote:
> So, I've got lots of C code wrapped up in guile, and I'd like to declare
> many of these functions to be pure functions, side-effect-free, thus
> hopefully garnering some optimizations. Is this possible? How would I do
> it? A cursory
So, I've got lots of C code wrapped up in guile, and I'd like to declare
many of these functions to be pure functions, side-effect-free, thus
hopefully garnering some optimizations. Is this possible? How would I do
it? A cursory google-search reveals no clues.
To recap, I've got functions f and
15 matches
Mail list logo