lexical-closures

    2熱度

    3回答

    我正在研究JavaScript框架。我有幾個獨立的腳本,如下所示: core.modules.example_module = function(sandbox){ console.log('wot from constructor ==', wot); return{ init : function(){ console.log('wot from i

    3熱度

    3回答

    Common Lisp中我可以不被暗示任何語法錯誤評估的代碼(在SBCL)下面的代碼片段:當我嘗試評估的相應方案片斷 (let ((x 0)) (defun my-incf (y) (setf x (+ x y))) (defun my-decf (y) (setf x (- x y)))) MY-DECF CL-USER> (my-incf 1)

    8熱度

    4回答

    我正在嘗試創建curry function,它可以應用於任何函數並返回另一個函數,並應用一個參數。 屬性,我想有: 如果函數只有一個參數,咖喱函數返回值: F(一);咖喱(f,x)= f(x); 如果函數有很多參數currey應該重試curry函數: g(a1,a2,..,aN);咖喱(g,x)= g2(a2,..,aN):g2(a2,.. aN)= g(x,a2,...,aN) curry函數的

    0熱度

    3回答

    計劃1: #include <iostream> std::string Hello(void){return "Hello";} std::string World(void){return "world!";} int main(){ std::cout << Hello() << " " << World() << std::endl; } 功能您好()和世界()

    5熱度

    1回答

    有沒有一種方法可以像使用macrolet一樣進行詞法關閉?我想要做的就是讓下面的宏本地遞歸輔助函數調用每個組合的功能,而不是生成因爲它現在要求在REPL結果宏列表: CL-USER> (combinations nil '(1 2 3) '(4 5 6)) ((1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6)) 我想是一個宏,它接受一個

    0熱度

    2回答

    我有下面的代碼是需要一個封閉的: var numItems = document.getElementsByClassName('l').length; for (var i = 0; i < numItems; i++) { document.getElementsByClassName('l')[i].onclick = function (e){ preview(thi

    2熱度

    1回答

    關閉過的細微差別 我一直在試圖理解JavaScript的功能組成的技術和我想出了一個玩具準MVC他的工作代碼來說明我的問題: var modelFactory = function() { var _state = false; var _listener = null; var _updateView = function() { _

    28熱度

    5回答

    我在網上閱讀關於封閉。我想知道C++是否有內置的閉包工具,或者有什麼方法可以用C++實現閉包?