continuations

    2熱度

    1回答

    我有一組模塊需要初始化,其中3個模塊需要很長時間,而其他模塊只需很少的時間來初始化。目前,如果在同一個線程上執行所有這些操作,則需要很長時間,例如, foreach (var m in modules) { var md = m; md.Initialise(); } ,所以我想是這樣 也試過: Parallel.ForEach(modules, m => m.Init

    2熱度

    1回答

    我有時間難以轉換一個簡單的CPS功能 這是一個CPS風格平方函數 -- from : http://en.wikibooks.org/wiki/Haskell/Continuation_passing_style square :: Int -> Int square x = x * x square_cps :: Int -> ((Int -> r) -> r) square_cps

    3熱度

    1回答

    我目前正在嘗試使用Petricek和Skeet(2010)的實際函數編程一書學習f#,但在使用延續避免堆棧溢出時遇到了問題。 我一直遇到的問題是使用continuations的代碼在f#interactive中啓動時工作正常,但在將代碼放入program.fs文件時仍然會導致堆棧溢出,然後通過Visual中的調試器啓動它工作室。 我不清楚爲什麼會發生這種情況,如果有人能給我一個解釋爲什麼會發生這種

    6熱度

    2回答

    讓我們考慮打破了原本的摺疊非終止: (call/cc (lambda (folded) (stream-fold (lambda (acc v) (if (< v 5) (cons v acc) (folded acc))) '() (in-naturals 0)))) ; returns '(4 3 2 1 0)

    1熱度

    1回答

    我與SICP一起工作,運動2.29-b讓我有機會在穿越手機和分支時獲得延續傳球風格。 爲了簡化故事,每個手機都有左右分支,它們由長度和數字權重或其他手機組成。這個問題要求找到手機的總重量。 第一相互遞歸解決方案之後,很簡單,我嘗試併成功實施了CPS'之一: (defn total-weight-cps [mobile] (letfn [(branch-weight-cps

    2熱度

    1回答

    我有3點方法的名稱(步驟1,步驟2,步驟3),以及其中的一個具有密集的計算。 我情況怎麼樣第一步和第二步是相互獨立的,和第三步只能第一步 這是我的代碼 static void Main(string[] args) { Console.WriteLine("Step1, Step2and Step3are independent of each other.\n"); Co

    2熱度

    2回答

    我有以下方法: private void GetHistoricalRawDataFromTextFiles(MessageHeader header, HistoricalRawDataFromTextFileSubscriptionDto dto) { var computeInstance = GetComputeInstance(dto.SubscriberId, dto.Co

    0熱度

    1回答

    鑑於這樣的事情: .ContinueWith((_, o) => this.Foo(), null, TaskContinuationOptions.OnlyOnRanToCompletion) .ContinueWith((_, o) => this.Bar(), null, TaskContinuationOptions.OnlyOnFaulted) .ContinueWith((_, o

    0熱度

    2回答

    所以我有一個延續定義: var task = _httpClient.SendAsync(request, cts.Token); task.ContinueWith(i => { /* TODO: log */ }, TaskContinuationOptions.OnlyOnCanceled); var response = await task.ConfigureAwait(f

    4熱度

    1回答

    考慮可愛的小HoleyMonoid庫,它可以讓你建立輸入參數可變類printf函數如下: {-# LANGUAGE NoMonomorphismRestriction #-} import Control.Category import Data.HoleyMonoid import Prelude hiding ((.), id) foo = now "hello "