![](/img/trans.png)
[英]Evaluate postfix (Stack python)
我到目前為止是:Stack = ArrayStack() def evaluate(postfix_str, Stack): for c in postfix_str: if c not in '+-*/()': Stack.push(int(c) ...
[英]Evaluate postfix (Stack python)
我到目前為止是:Stack = ArrayStack() def evaluate(postfix_str, Stack): for c in postfix_str: if c not in '+-*/()': Stack.push(int(c) ...
[英]my c++ postfix converter using stack library
我是 CS 的第二年,我正在嘗試通過以下步驟創建中綴到后綴轉換器: 1.如果字符是數字打印 2-如果是'(',則將其添加到堆棧中 3-如果是')'然后彈出到output直到它到達'(' 4-如果是運算符,則從堆棧中彈出,直到可以根據運算符的優先級將其推入堆棧 5-顯示最終的后綴方程問題是我需要一 ...
[英]Infix to Postfix Converter in C++ gives no output
我制作了一個函數infixToPostfix() ,它將中綴表達式轉換為后綴表達式。 但是我的程序在運行時不會產生任何輸出。 請指出我程序中的錯誤。 代碼: 執行: 邏輯: 我創建了一個字符指針變量來保存我們的后綴表達式。 現在,我們遍歷我們的中綴表達式。 如果我們收到一個操作數,我 ...
[英]List of the Prelude haskell operators, with precedence level
我在哪里可以找到 Prelude 和基本包中的中綴 Haskell 運算符列表,以及它們的優先級,以及它們是右關聯還是左關聯? 我知道這些信息可在文檔中找到,但它們都散布在各處,並與描述和示例混合在一起。 我只想要這些運算符的列表,沒有任何描述,按它們的優先級和關聯性排序。 這就對了。 ...
[英]Defining the associativity of a custom operator in Haskell
我正在使用自定義運算符infix 、 infixl和infixr 。 現在我很困惑。 我為列表乘法編寫了一個自定義運算符,並認為將其聲明為沒有方向關聯性的簡單中綴運算符會自動提供nr * list和list * number這兩種情況,因為它們可以隨意互換. 現在, 3 * [1, 2, 3] [1 ...
[英]Why can't I use Data.Function.(&) in the same expression as Control.Arrow.(>>>)?
為什么我不能在與Control.Arrow.(>>>)相同的表達式中使用Data.Function.(&) Control.Arrow.(>>>) ? 我在 F# 上花了很多時間之后學習了 Haskell,我發現從右到左的符號很難理解更長的管道。 (我 ...
[英]R: conflict between two definitions of (infix) operator: how to specify package?
在 R 中,每當兩個包定義相同的 function 時,很容易指定哪個 package 與pkg::foo一起使用。 但是,當沖突的 function 是一個中綴運算符,即使用%%定義時,你怎么辦? 例如, ggplot2和crayon都定義了%+% 。 有沒有一種方法可以默認使用ggplot2的 ...
[英]Raku infix operator in method-like syntax
在 Raku 中,中綴運算符可以像函數一樣使用,例如: 1 + 2 ; # 3 infix:<+>(1, 2) ; # 3 [+] 1, 2 ; # 3 前綴運算符可以與類似方法的語法( methodop )一起使用: -1 ; ...
[英]Is it possible to use kotlin infix functions and swift infix operators the same way (with equal naming)?
我在 kotlin 中有一個中綴 function ,可以這樣調用: 現在我試圖在 swift 中做同樣的事情。 我已經認為我可以像下面那樣做,但這似乎不起作用: 錯誤:'eq' 被認為是標識符,而不是運算符中綴運算符 eq 有沒有辦法讓這個工作? ...
[英]How to implement a default method for a custom infix operator in a protocol extension
我正在嘗試將自定義比較中綴運算符==^實現為標准相等運算符==的精簡版本我的應用程序主要面向協議,因此我試圖在協議擴展中實現默認方法static func ==^ 。 然而,當我讓我的 class 符合協議時,我得到一個Type 'MySourceNode' does not conform to ...
[英]How to specify implicit arguments for infix operators?
假設我有一個操作員 (其中Tensor采用Vect和類型,但這在這里並不重要)。 如果我想指定tail ,我知道我可以通過將@@變成 function (@@)來添加到a @@ b 但這在某種程度上違背了它被中綴的意義。 什么是慣用語? ...
[英]Common Lisp Read Macro for “lazy infix or,” to destructure keywords
我有一個 Common Lisp 閱讀器宏來解析“或”關系的延遲/延遲聲明,使用由 pipe 字符(“|”)分隔的中綴語法以及標准列表括號和關鍵字文字。 考慮 (:a:b|:c) 形式——它表示一個 2 部分元組,其中第一個元素肯定是:a,第二個元素是:b 或:c。 例如,可以推斷出整個元組的有效 ...
[英]F# infix operators in c#?
在 F# 中,為二元運算符聲明中綴運算符並不少見。 但是如果我們嘗試在 C# 中使用它們,它們是如何表示的,因為在 C# 中無法聲明中綴運算符? 玩具示例 ...
[英]How to resolve the segmentation fault in this code?
我正在嘗試制作一個中綴計算器,我目前正在嘗試將字符數組中輸入的數字轉換為雙精度計算器。 這是我的代碼: 樣本輸入 它停止工作並將分段錯誤作為標記位置的錯誤。 ...
[英]How do I parse infix instead of prefix with Haskell?
我需要幫助我嘗試用 Haskell 編寫的這個程序。 我已經寫了大部分,這里是我基本上想要做的事情: 當我寫 解析“a + b” 在終端中,我希望將其作為輸出: 加(字“a”)(字“b”) 當我寫 解析“a - 2 * b + c” 在終端中,我希望將其作為輸出: 減號(單詞 ...
[英]Why doesn't the infix function := from tidyverse need the % around it?
如果要創建自己的中綴函數,則需要采用%fun_name%形式。 為什么:= of tidyverse不是這種情況? 此外,與運營商相同!! ,也形成tidyverse 。 ...
[英]How and why is a GNAT.Strings.String_List use clause disallowed? How can you use System.Strings.String_List.“&” with infix notation?
發帖有兩個原因:(1)我被困在無用的編譯器錯誤上太久了,因為這樣一個簡單的問題,我希望下一個人通過谷歌搜索這些消息來找到我(或其他)的答案,以及(2)我仍然不明白不允許使用子句,所以我自己的答案真的不完整。 為了使用幾乎相同的參數在兩個地方調用程序,我想使用 '&' 附加到默認列表內聯: ...
[英]Evaluate infix string expression consisting of only addition and multiplication
如何評估僅由+和*運算符組成的中綴字符串表達式。 (無括號)。 示例 1: 輸入: "1+2*3" Output: 7 示例 2: 輸入: "1+2*3+4" Output: 11 這是我到目前為止的代碼(沒有給出正確的結果),我想知道我是否可以用一個堆棧(或沒有)來完成 注意:不想使用任何非 ...
[英]How does R evaluate these weird expressions?
I was trying to make Python 3-style assignment unpacking possible in R (eg, a, *b, c = [1,2,3], "C" ), and although I got so close (you can check ou ...
[英]Function to split the input expression into token units(python)
運算符和操作數之間可能有空格。 運算符和操作數都必須作為列表中的字符串返回。 操作數必須是浮點數。 例如。 輸入: 1+2 *3/(4+5) output: ['1.00', '+', '2.00', '*'......] 我不確定出了什么問題。 如果你教我,我將不勝感激。 ...