i wanted to ask this: I have in mathematica :
step := {{0, 1}, {1, 0}, {0, -1}, {-1, 0}} [[RandomInteger[ {1, 4}] ]]
step --> this takes one list from above (for example {0,1})
steps2D[n_] := Table[step, {n}]
and i did:
a=[0,1];b=[1,0];c=[0,-1];d=[-1,0];
list=[a;b;c;d]
step=@ (rand) rand(1,list) -->> i must extract from here randomly one pair..
step
steps2D=@ (n) arrayfun(step,n);
I have 2 problems: 1) I can't extract from my list randomly one pair. 2) I don't know if i have the step2D right.
EDIT-->> The code continues :
Walk2D[n_] := FoldList[Plus, {0, 0}, steps2D[n]]
Walk2D[10]
LastPoint2D[n_] := Fold[Plus, {0, 0}, steps2D[n]]
LastPoint2D[100]
I did this :
Walk2D=@ (list,n) cumsum(steps2D(list,n));
Walk2D(list,10)
LastPoint2D = @ (Walk2D) (Walk2D(end));
walk1=Walk2D(list,100);
LastPoint2D(walk1) -->> This gives me only one number and not a pair as it should