POV-Ray : Newsgroups : povray.advanced-users : Using a macro as an _argument_ for another macro : Using a macro as an _argument_ for another macro Server Time
4 Feb 2023 22:34:08 EST (-0500)
  Using a macro as an _argument_ for another macro  
From: Bald Eagle
Date: 19 Jan 2023 07:00:00
Message: <web.63c9309e681587261f9dae3025979125@news.povray.org>
Working on sorting algorithms.  I thought I had some of these coded in the
past....   But I guess I'll just rewrite them.

Out of:

Bubble Sort
Selection Sort
Insertion Sort
Quick Sort
Merge Sort
Shell Sort
Heap Sort

I got the first 4 coded, and was thinking about timing them.

(Also, the way Quick sort is recursive, it's not straightforward to code and
keep the original unsorted array unmodified - so I think I'll make that a
macro-within-a-macro.)

My idea was to have a "wrapper", where a timing macro would take a sorting macro
as an argument, log the start time, run the macro, log the end time, and then
spit the elapsed time out to the #debug stream.

Here's what I'm doing at 7am, which obviously does NOT work, but it illustrates
the idea with pseudocode / unworkingcode.

#macro Print () #debug "inner macro \n\n" #end

#macro Test (optional Directive)

 Directive

#end

Test (Print())





Do we think there might be a way to bamboozle the parser into letting one macro
run another macro, being passed in as an argument?   ParseString perhaps?


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.