Skip to content

Commit

Permalink
fix #252: demote on take
Browse files Browse the repository at this point in the history
  • Loading branch information
tavmem committed Sep 29, 2014
1 parent 9c7562f commit f689f4f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ko.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ K kclone(K a)//Deep copy -- eliminate where possible

K collapse(K x) //oom
{
if(xt==1 && xn==1) R x;
K z;
if(1==xn){ z=ci(*kK(x)); cd(x);}
else z=demote(x);
Expand All @@ -88,6 +89,7 @@ K demote(K a)//Attempt to force unnaturally occurring lists into vectors
else if(2==p)DO(n,kF(z)[i]=*kF(kK(a)[i]))
else if(1==p)DO(n,kI(z)[i]=*kI(kK(a)[i]))
cd(a);
if(z->t==-1 && z->n==1) z->t=1;
R z;
}
K promote(K a)//Identity on lists. Lists from vectors. Pseudo-enlist on atoms (always 0-lists).
Expand Down
1 change: 1 addition & 0 deletions tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Z I tests02()
TC(_n, {a:1;a+a}0;a)
TC(99#1, {1}/:!99)
TC(1 2, 2#(1;2;3.0))
TC(1 2, -1_(1;2;3.0))
TC({x^2}, f:{x^2};.`f)
TC(1, (1+)~(1+))
TC(0, (1+)~(2+))
Expand Down
2 changes: 1 addition & 1 deletion vg.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ K drop(K a, K b)
else if(-1==bt)DO(zn,kI(z)[i]=kI(b)[i+c])
else if( 0==bt)DO(zn,kK(z)[i]=ci(kK(b)[i+c]))

R z;
R demote(z);
}

K cut(K a, K b)
Expand Down

0 comments on commit f689f4f

Please sign in to comment.