Source file evallist.icn
############################################################################
#
#	File:     evallist.icn
#
#	Subject:  Procedure to produce a list generated by expression
#
#	Author:   Ralph E. Griswold
#
#	Date:     July 15, 1995
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This procedure takes an expression, produces a program encapsulating it,
#  and puts the results written by the program in a list.
#
#  It is called as evallist(expr, n, ucode, ...) where expr is an expression
#  (normally a generator), n is the maximum size of the list, and the
#  trailing arguments are ucode files to link with the expression.  
#
############################################################################
#
#  Requires:  system(), /tmp, pipes
#
############################################################################
#
#  Links:  exprfile
#
############################################################################

link exprfile

procedure evallist(expr, n, ucode[])	#: list of values generated by Icon expression
   local input, result

   push(ucode, expr)			# put expression first

   input := exprfile ! ucode | fail

   result := []
   every put(result, !input) \ n

   exprfile()				# clean up

   return result

end

This page produced by UniDoc on 2021/04/15 @ 23:59:45.