} // map() public static List <O> map <I, SuperI, O> (IEnumerable <I> items, NFunc <SuperI, O> func) where I : SuperI { List <O> result = new List <O>(); foreach (I item in items) { O output = func.eval((SuperI)item); result.Add(output); } return(result); } // map()
} // read() public E read <E>(NFunc <NInputStream, E> readCallback) { NInputStream in_stream = read(); try { E result = readCallback.eval(in_stream); return(result); } catch (Exception e) { throw new NResourceException("Error occurred in read callback", e); } finally { FileHelper.safeClose(in_stream); } } // read()