Hi Martin,
can you give some explanation for this complicated setup?
https://github.com/hemmecke/fricas/blob/martin-baker/src/algebra/graph.spad.pamphlet#L543
You seem to want to store the loop with the smallest index first.
Obviously, this wish cannot have any mathematically relevant meaning,
since if I give you the list
[10009, 10001, 10008]
then after the for loop
minValue:NNI := 10000::NNI
minIndex:NNI := 0::NNI
for i in 1..#li repeat
if (li.i)<minValue then
minValue := li.i
minIndex := i
we will still have minIndex=0 and thus return the array with the entries
in the above order.
I also don't like the "pretend" in these lines:
entries(lp:%):List NNI ==
entries(lp pretend PrimitiveArray(NNI))$PrimitiveArray(NNI)
"pretend" should almost nowhere be visible in SPAD code. For this
particular case maybe you want to look at
http://groups.google.com/group/fricas-devel/browse_thread/thread/a547ad5e2765e3e7
I.e. replace "Rep :=" by "Rep ==" and define "rep" and "per" as functions
rep(x: %): Rep == x pretend Rep
per(x: Rep): % == x pretend %
inside the domain or as macros at top level
rep x ==> (x@%) pretend Rep
per x ==> (x@Rep) pretend %
(This would be the only places where I'd accept "pretend".)
((NB: Bill, since I basically neither want to see "Lisp" nor "pretend"
in a spad file (since they are inherently type unsafe). That is my
reason for why I want ")include". In fact, I'd also like to specify
which things are in scope while compilation happens. Just like in Aldor
compiling a .spad file should start with empty knowledge. Imports should
be explicit.))
For the "macro" variant, you must merge your branch with trunk since
parametrized macros have only be added some days ago.
After that your code will look like
entries(lp:%):List NNI == entries rep lp
which I find tremendously more readable. And the rep makes it clear that
you rely on functionality of the domain that you have chosen as a
representation. The SPAD compiler is able to figure out that it has to
call entries$Rep, but you should not use "Rep:=" for this to work.
Always writing "PrimitiveArray(NNI)" in such places makes it hard to
easily change the representation and IMHO hides the intend of the code.
Ralf
On 01/18/2012 11:48 AM, Martin Baker wrote:
Are you interested in an implementation of graph theory I have put
here:
https://github.com/martinbaker/fricas/blob/master/src/algebra/graph.spad.pamphlet
If so there is a tutorial here:
http://www.euclideanspace.com/maths/standards/program/mycode/discrete/graph/
Martin
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.