If you were given the task of generating a set of text files whose different
versions differed only in a set of numerical values, which tool would you
choose?
The first tool that jumped to my mind was the M4 preprocessor, but it
appears it doesn't handle algebraic operations that well.
Thanks in advance,
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1745)
|
5/27/2012 4:29:35 PM |
|
Rui Maciel <rui.maciel@gmail.com> wrote:
> If you were given the task of generating a set of text files whose different
> versions differed only in a set of numerical values, which tool would you
> choose?
diff?
> The first tool that jumped to my mind was the M4 preprocessor, but it
> appears it doesn't handle algebraic operations that well.
m4 doesn't seem to do anything well except edit sendmail.cnf files
|
|
0
|
|
|
|
Reply
|
fritz9111 (34)
|
5/28/2012 12:16:27 AM
|
|
Fritz Wuehler wrote:
> Rui Maciel <rui.maciel@gmail.com> wrote:
>
>> If you were given the task of generating a set of text files whose
>> different versions differed only in a set of numerical values, which tool
>> would you choose?
>
> diff?
The objective is to generate a set of files with present different values
specified by a parameter. For example, let's assume we have this template:
<example>
Line (0,0) (XX,YY)
</example>
And, based on this template, a user intended to define N different data
files, each one with different values for (XX, YY), with the values for XX
and YY being defined in terms of an arbitrary algebraic expression.
>> The first tool that jumped to my mind was the M4 preprocessor, but it
>> appears it doesn't handle algebraic operations that well.
>
> m4 doesn't seem to do anything well except edit sendmail.cnf files
After a bit of digging, I also ended up with the idea that m4 is limited to
the point it is essentially useless. Someone correct me if I'm wrong, but
it appears m4 only supports algebraic operations on integers. If it doesn't
support floating point operations, or even decimal fractions, then it is
essentially irrelevant for any task which involves non-integer numberical
values.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1745)
|
5/28/2012 11:32:13 AM
|
|
"Rui Maciel" <rui.maciel@gmail.com> wrote in message
news:jpvnnr$e2e$1@speranza.aioe.org...
> Fritz Wuehler wrote:
>
>> Rui Maciel <rui.maciel@gmail.com> wrote:
>>
>>> If you were given the task of generating a set of text files whose
>>> different versions differed only in a set of numerical values, which
>>> tool
>>> would you choose?
>>
>> diff?
>
> The objective is to generate a set of files with present different values
> specified by a parameter. For example, let's assume we have this
> template:
>
> <example>
> Line (0,0) (XX,YY)
> </example>
>
> And, based on this template, a user intended to define N different data
> files, each one with different values for (XX, YY), with the values for XX
> and YY being defined in terms of an arbitrary algebraic expression.
Why do you need a preprocessor? It seems to me that any simple language will
do the job.
Or is this example embedded in a mass of other text? Perhaps a more complete
example is needed. Even then, if the input is line oriented (so you don't
need macro expansions in the middle of a line, and don't need nested
macros), a simple language might still work.
--
Bartc
|
|
0
|
|
|
|
Reply
|
bc (2210)
|
5/28/2012 12:51:07 PM
|
|
Rui Maciel wrote:
> The objective is to generate a set of files with present different values
> specified by a parameter. For example, let's assume we have this
> template:
>
> <example>
> Line (0,0) (XX,YY)
> </example>
>
> And, based on this template, a user intended to define N different data
> files, each one with different values for (XX, YY), with the values for XX
> and YY being defined in terms of an arbitrary algebraic expression.
Have you considered PHP ? A language I detest, but maybe suitable for your
purpose.
Or just write a little pre-processor in your lanugage of choice (Lisp?) and
have done. It's often quicker and easier to re-invent a wheel than to try to
find the right one in the haystack.
-- chris
|
|
0
|
|
|
|
Reply
|
chris.uppal (3970)
|
5/28/2012 1:45:32 PM
|
|
BartC wrote:
> Why do you need a preprocessor? It seems to me that any simple language
> will do the job.
As the task consisted of, basically, defining a template for a document and,
from that, create a series of documents by replacing a given variable with a
value, it appeared that the best way to go around doing this would be with a
macro processor.
> Or is this example embedded in a mass of other text?
Yes. Although the example I've provided is a bit slimsy on the details,
basically what I intended to do was create a template for a document that
defined a model in terms of a set of parameters. Then, that template would
be used to create a series of models which reflected the way a given
parameter was tweaked.
> Perhaps a more
> complete example is needed. Even then, if the input is line oriented (so
> you don't need macro expansions in the middle of a line, and don't need
> nested macros), a simple language might still work.
Since I've started this thread, I've started writing a small Perl script to
generate the models. Perl's support for here-document string literals
appears to do a decent job at this.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1745)
|
5/28/2012 3:19:27 PM
|
|
Chris Uppal wrote:
> Have you considered PHP ? A language I detest, but maybe suitable for
> your purpose.
The thought did crossed my mind, but as I didn't had any PHP interpreter
currently installed on my computer, I opted to look for other alternatives.
> Or just write a little pre-processor in your lanugage of choice (Lisp?)
> and have done. It's often quicker and easier to re-invent a wheel than to
> try to find the right one in the haystack.
Yes, I've opted for a small Perl script. It may not be the ideal solution,
but it does work.
How would you do do this sort of task with Lisp?
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1745)
|
5/28/2012 3:21:55 PM
|
|
Rui Maciel wrote:
> Since I've started this thread, I've started writing a small Perl script
> to generate the models. Perl's support for here-document string literals
> appears to do a decent job at this.
I've tried to post the script, but it appears that aioe.org doesn't want
that to happen.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1745)
|
5/28/2012 3:43:07 PM
|
|
On 05/28/12 04:29 AM, Rui Maciel wrote:
> If you were given the task of generating a set of text files whose different
> versions differed only in a set of numerical values, which tool would you
> choose?
sed?
--
Ian Collins
|
|
0
|
|
|
|
Reply
|
ian-news (9878)
|
5/28/2012 7:50:52 PM
|
|
On 5/28/2012 8:21 AM, Rui Maciel wrote:
....
> Yes, I've opted for a small Perl script. It may not be the ideal solution,
> but it does work.
I don't like perl for large programs, but it is a good tool to have
around for this sort of task.
Patricia
|
|
0
|
|
|
|
Reply
|
pats (3215)
|
5/28/2012 11:33:00 PM
|
|
|
10 Replies
45 Views
(page loaded in 0.099 seconds)
|