smlnj

    2熱度

    1回答

    type VAR = identifier type code = instruction list type environment = identifier list type EXPR = environment -> code * environment fun ADD_OP expr expr' env = DUMMY fun SUB_

    1熱度

    1回答

    我試圖用SML將一個值插入到「註冊」中。如果列表(或寄存器)沒有在該索引處定義,我需要在該索引之前創建一個0的列表。我嘗試了以下方法,但無法使其工作。 fun storeInReg [] valIns idx = if idx = 0 then [valIns] else 0::storeInReg([] valIns (idx-1)) | storeIn

    0熱度

    1回答

    這種語言的語法很混亂。 fun bar a = print (Int.toString a); 0 編譯。不知道爲什麼emacs縮進0。 fun bar a = print (Int.toString a) 0 引發錯誤。 Error: operator is not a function [tycon mismatch] operator

    0熱度

    1回答

    爲什麼編譯? fun foo (h::t) = h = hd(t); 但這並不 fun foo (h::t) = PolyML.print (h::t); print "\n"; h = hd(t); ? Value or constructor (h) has not been declared Found near =(h, hd(t)) V

    1熱度

    1回答

    在Prolog中,您可以激活跟蹤模式進行調試。 ML顯然沒有這樣的事情。至少有一個exit()或abort()?當與調試打印語句結合使用時,A sleep()對於從Prolog近似跟蹤模式也很有用。

    -1熱度

    1回答

    我在Mac上遇到了SML/NJ問題。我下載了正確的原始pgk文件。 SML/NJ安裝在正確的道路上:/usr/local/smlnj/bin/sml但是當我嘗試運行sml(命令:SML)出現以下消息: -bash: sml: command not found. 我覺得現在的問題是,我有OSX 10.11.3在我的Mac 。

    2熱度

    3回答

    我想在sml中創建堆棧,我嘗試過使用列表;但我無法將元素添加到列表中。我試圖從輸入文件讀取行,說如果行說: push 5 push 9 add quit 然後我想輸出文件是: 14 因爲5 + 9是14 到目前爲止,我能夠創建布爾函數來識別行是推還是數字。 fun is_digit (c) = #"0" <= c andalso c <= #"9"; fun is_Push (c)

    0熱度

    1回答

    我沒那麼熟悉SML但我已經寫了下面的程序: datatype 'a bin_tree = Leaf of 'a | Node of 'a bin_tree * 'a bin_tree fun height Leaf (x) = 0 | height Node (l1,l2) = 1 + Int.max(l1,l2) fun is_balanced Leaf (x) = true |

    2熱度

    1回答

    我有一個正在正確工作的函數... 但是,不幸的是在顯示它之前構造了一個很大的字符串。 我想顯示每個字符串,而不是直接concatening人,但我不知道該怎麼辦呢? 下面是函數: fun getBlocked w = case BlockingMgr.listBlockedSuccessors w of nil => "" | ws => concat (

    4熱度

    1回答

    我一直在學習一些函數式編程,並決定拿起ML作爲我的車輛這樣做。只有幾天,我拿起了ML,也許花了大約5-6小時的時間來解決一些問題。無論如何,關於我的問題。 通常,當學習一門語言時,我會通過一些項目歐拉問題來了解語法和操作。所以我一直在研究一個需要階乘函數的問題。雖然我不斷收到溢出錯誤,但通常要在其他語言中解決這個問題,我會添加一些記憶或者依賴標準庫來避免它,但是我對ML的經驗不足使得記憶似乎是陌生