;Sayings
friendly := ["hello there!", "Howdy!", "Greetings friend!", "hi there"]
helpful := ["x next to y and z", "this is helpful", "The sky is blue"]
other := ["where is my toaster", "do it", "ju
對函數參數進行約束的最佳做法是什麼? 類似於一個檢查對數函數內部的檢查負數: SELECT log(-1, 1)
拋出錯誤: [2201E] ERROR: cannot take logarithm of a negative number
到目前爲止,我發現了一個辦法做到這一點使用PL/pgSQL的函數體內部,但它對我來說不是一個好的解決方案。 有沒有辦法在函數聲明中進行約束? 我希望看
此功能的簽名令我困惑,所有在線信息讓我感到困惑。有人可以向我解釋功能的簽名,也許給我一個例子嗎? sort3 :: Ord a => (a -> a -> Ordering) -> [a] -> [a]
sort3 cmp xs | length(xs) < 1 = xs
這是我得到的錯誤。 Couldn't match expected type ‘a -> a -> Ordering’
所以我有這個功能 intCMP :: Int -> Int -> Ordering
intCMP a b | a == b =EQ
| a < b = LT
| otherwise = GT
和定義 xs = [1,2,3]
我試圖找到有關該列表的信息,但我有troouble傳球元素融入intCMP 這此列表是我想要做的 intCMP head(xs) 1