English 中文(简体)
1. 以简单的功能语言执行,而不进行zy评价
原标题:Implementing fold in simple purely functional language without lazy evaluation

I am trying to implement a simple functional language for automatic program synthesis. The data structure is a graph of functions and values, which compiles down to javascript. The following graph should be a fold function. funcApp nodes are connected to a function node and a number of value nodes, and it applies the function to the values. arg0 is the list, arg1 is an initial value (z) arg2 is the function to be applied.

“entergraph

这相当于组合办法的定义(尽管我的语言并非计划,但是图表)。

(define (foldr f z xs)
   (if (null? xs)
       z
       (f (car xs) (foldr f z (cdr xs)))))

问题是,由于没有特别运营商,因此一切,特别是<条码>,只要“<>/代码”只是正常功能。 这样,方案永远不会终止,而是达到最大的深度,因为其他条款总是被计算。

我假定,这个问题在某些语言中通过zy评价得到解决。 因此,我的问题是:是否有一套功能性文件,没有这种无限的重复,2)如果有必要,就开始考虑将评价应用到简单的语言上。

问题回答

I think it s pretty uncommon to evaluate under binders (and, in particular, to evaluate the body of lambdas), so I think the standard solution to lazifying a strict language is to introduce a lambda. I don t know the scheme syntax, but in Haskell syntax, if you wanted x to be a lazy parameter to a strict function f, you might write something like f (() -> x) (and modify f appropriately to expect such lambdas, and call them at the moment you want to un-lazy them).

您可以把两处“快报”编成“th”,并根据情况称呼适当的un。 如果以这种方式书写计划的正式定义,我就感到惊讶。





相关问题
Recursive same-table query in SQL Server 2008

I have the following table in a SQL Server 2008 database: Id Name ParentFolder -- ---- ------------ 1 Europe NULL 2 Asia NULL 3 Germany 1 4 UK 1 5 China ...

Finding a class within list

I have a class (Node) which has a property of SubNodes which is a List of the Node class I have a list of Nodes (of which each Node may or may not have a list of SubNodes within itself) I need to be ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签