Skip to content

Commit

Permalink
ARGV can be used as regular pan list (tested with pan 10.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird committed Feb 8, 2016
1 parent 853d091 commit 25e6f6f
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions pan/functions.pan
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ function push = {
# Get the reference to SELF or create an empty list
# as necessary.
if (exists(SELF) && is_list(SELF)) {
v = SELF;
merge(SELF, ARGV);
} else if (!exists(SELF) || !is_defined(SELF)) {
v = list();
ARGV;
} else {
error("push can only be applied to a list");
};

# Cannot use merge or reference ARGV directly
i = 0;
while (i<ARGC) {
v[length(v)] = ARGV[i];
i = i + 1;
};
v;
};


Expand Down Expand Up @@ -102,38 +94,23 @@ function push_if = {
};

if (ARGV[0]) {
# Get the reference to SELF or create an empty list
# as necessary.
delete(ARGV[0]);

if (exists(SELF) && is_list(SELF)) {
v = SELF;
merge(SELF, ARGV);
} else if (!exists(SELF) || !is_defined(SELF)) {
v = list();
ARGV;
} else {
error("push_if can only be applied to a list");
};

# Merge the arguments into the given array. Neither the
# first/next or merge functions can be used because the
# ARGV array cannot be directly referenced.
#
# Start index at one to avoid merging boolean flag.
i = 1;
while (i<ARGC) {
v[length(v)] = ARGV[i];
i = i + 1;
};

} else {

# Return either SELF or an empty list.
if (is_defined(SELF)) {
v = SELF;
SELF;
} else {
v = list();
list();
};
};

v;
};


Expand Down

0 comments on commit 25e6f6f

Please sign in to comment.