How to substitute some item in different depth list
In Lisp, the list is very useful, it is more flexible than the ordinary array in other Language such as
Fortran or Basic.
But when I translate some other Language to Lisp, I am always confuse of how to deal with the
translation between array and list.
For example,
A=[ x y z ....]
B=[[a1 b1 c1][a2 b2 c2][.........]]
C=[ [[x1 y1 z1][x2 y2 z2]] [[x3 y3 z3][x4 y4 z4]] [...]]
In other Language, we often get the value of a array by:
Value=A[5] or B[6,5] or C[3,4,5]
or put the value by:
A[5] or B[6,5] or C[3,4,5]=Value
but in Lisp, I found it is not so easy
when get a value is easlier, we should use (nth (nth (nth ))),
but when put a value, it is trouble, maybe we can write a function, such as SUBSTI(new position
list) to substitute, but when the list is multi-depth, such as B or C or more deep list. Maybe we
should write several defun to adapt the different situation.
Because many scientific code are written by other Language, sometimes I need to translate it to
Lisp, for example, inverse matrix, I am not familar with safearray in vlisp and hope it could be
done by Lisp.
so my question is: How can we write a more general function to substitute the item in the list
with multi-depth, no matter how deep the list is.
For example, we can
PUT(C, 1,2,3, z2a) to substitute the z2 in C
PUT(B, 2,2,b2a) to substitute the b2 to b2a in B
GET(B, 2,2) to get the value of b2, and GET(A,3) to get the value of z
Maybe I get a wrong way of the problem, Maybe it is easy, but I hope you could help me.