Show
Ignore:
Timestamp:
09/16/07 01:53:07 (14 months ago)
Author:
ryporter
Message:

adding support for first() to pugs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/List.hs

    r16573 r17865  
    55    op1Min, op1Max, op1Uniq, 
    66    op2Pick, 
    7     op2ReduceL, op2Reduce, op2Grep, op2Map, op2Join, 
     7    op2ReduceL, op2Reduce, op2Grep, op2First, op2Map, op2Join, 
    88    sortByM, 
    99    op1HyperPrefix, op1HyperPostfix, op2Hyper, 
     
    331331    return $ VList vals 
    332332 
     333op2First :: Val -> Val -> Eval Val 
     334op2First sub@(VCode _) list = op2First list sub 
     335op2First list sub = do 
     336  (VList vals) <- (op2Grep list sub) 
     337  if (length vals) > 0  
     338    then return $ (vals !! 0) 
     339    else fail $ "Cannot call first() with a filter that removes all elements from the input list" 
     340 
    333341op2Map :: Val -> Val -> Eval Val 
    334342op2Map sub@(VCode _) list = op2Map list sub