Mercurial > repos > rhope
diff list.rhope @ 92:e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 02 Aug 2010 00:58:55 -0400 |
parents | 004f0fc8941f |
children | 5a08705f7610 |
line wrap: on
line diff
--- a/list.rhope Sat Jul 31 17:17:23 2010 -0400 +++ b/list.rhope Mon Aug 02 00:58:55 2010 -0400 @@ -277,3 +277,57 @@ } } +New Like@List[in:out] +{ + out <- List[] +} + +New Like@List Leaf[in:out] +{ + out <- List[] +} + +//TODO: Implement a more efficent version of this +_Tail[list, cur, dest:out] +{ + ndest <- [dest]Append[[list]Index[cur]] + [list]Next[cur] + { + out <- _Tail[list, ~, ndest] + }{ + out <- Val[ndest] + } +} +Tail[list,start:out] +{ + newlist <- New Like[list] + [list]Index[start] + { + out <- _Tail[list, start, newlist] + }{ + out <- Val[newlist] + } +} + +Concatenate[left,right:out] +{ + out <- Fold[Append[?], left, right] +} + +Print@List Leaf[list:out] +{ + If[[[list]Buffer >>]Length] + { + Print["List"] + { _Print Seq[list, [list]First] } + }{ + Print["List\n\t{Empty}"] + } +} + +Print@List[list:out] +{ + Print["List"] + { _Print Seq[list, [list]First] } +} +