Package net.sf.kpex.builtins

Source Code of net.sf.kpex.builtins.LazyHead

/*
* KernelProlog Expanded - Pure Java based Prolog Engine
* Copyright (C) 1999  Paul Tarau (original KernelProlog)
* Copyright (C) 2009  Michiel Hendriks
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
package net.sf.kpex.builtins;

import net.sf.kpex.prolog.Cons;
import net.sf.kpex.prolog.FunBuiltin;
import net.sf.kpex.prolog.Prog;

/**
* returns the first element of a lazy list
*/
public class LazyHead extends FunBuiltin
{
  public LazyHead()
  {
    super("lazy_head", 2);
  }

  @Override
  public int exec(Prog p)
  {
    Cons L = (Cons) getArg(0);
    return putArg(1, L.getHead(), p);
  }
}
TOP

Related Classes of net.sf.kpex.builtins.LazyHead

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.