01: /*
02: * @(#)shift.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.lib;
10:
11: import pnuts.lang.*;
12: import java.util.*;
13:
14: /*
15: * function shift(linkedList)
16: */
17: public class shift extends PnutsFunction {
18:
19: public shift() {
20: super ("shift");
21: }
22:
23: public boolean defined(int nargs) {
24: return nargs == 1;
25: }
26:
27: protected Object exec(Object[] args, Context context) {
28: if (args.length != 1) {
29: undefined(args, context);
30: return null;
31: }
32: return ((LinkedList) args[0]).removeFirst();
33: }
34:
35: public String toString() {
36: return "function shift(linkedList)";
37: }
38: }
|