Skip to content

Instantly share code, notes, and snippets.

@diakopter
Created October 31, 2010 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diakopter/657302 to your computer and use it in GitHub Desktop.
Save diakopter/657302 to your computer and use it in GitHub Desktop.
/// <summary>
/// Pops a value from a low level list (something that
/// uses the P6list representation).
/// </summary>
/// <param name="TC"></param>
/// <param name="LLList"></param>
/// <returns></returns>
public static RakudoObject lllist_pop(ThreadContext TC, RakudoObject LLList)
{
if (LLList is P6list.Instance)
{
List<RakudoObject> store = ((P6list.Instance)LLList).Storage;
int idx = store.Count - 1;
if (idx < 0)
{
throw new ArgumentOutOfRangeException("The P6list was empty");
}
RakudoObject item = store[idx];
store.RemoveAt(idx);
return item;
}
else
{
throw new Exception("Cannot use lllist_elems if representation is not P6list");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment