到目前为止,Go编程语言是否优化尾调用?如果没有,它是否至少优化了函数的尾递归调用?
最初Startup.cs,我们AddDataProtection()完全省略了调用。当我们尝试部署该应用程序时,我们看到了这一点:
System.Security.Cryptography.CryptographicException: The key {...} was not found in the key ring.
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[] protectedData, Boolean ignoreRevocationErrors, Boolean& requiresMigration, Boolean& wasRevoked)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
at Microsoft.AspNetCore.Session.CookieProtection.Unprotect(IDataProtector protector, String protectedText, ILogger logger)
warn: Microsoft.AspNetCore.Session.SessionMiddleware[7]
Error unprotecting the session cookie.
Run Code Online (Sandbox Code Playgroud)
当我添加到 时services.AddData.AddDataProtection().SetApplicationName("MyAppName");,ConfigureServices()我们现在在部署后看到
System.Exception: An error was encountered while handling the remote login. ---> System.Exception: Correlation failed.
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
at …Run Code Online (Sandbox Code Playgroud) https://wincent.com/wiki/HTTPS_access_to_Amazon_S3_buckets http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html
有什么办法可以使用Java SDK以路径样式而不是虚拟主机样式生成预先签名的S3临时URL吗?
编辑:澄清:
路径式手段 https://s3.amazonaws.com/my.bucket/my_item?...
虚拟主机风格意味着 https://my.bucket.s3.amazon.aws.com/my_item?...
我写了一个Haskell函数,用anagrams对单词进行分组.我正在尝试学习OCaml,但我对如何在OCaml中使用模式匹配感到困惑.有人可以帮我把这个翻译成OCaml吗?谢谢!
此函数获取字符串列表,并将其分区为字符串列表,按字母组分组.
import Data.List
groupByAnagrams :: [String] -> [[String]]
groupByAnagrams [] = []
groupByAnagrams (x:xs) = let (listOfAnagrams, listOfNonAnagrams) = (partitionByAnagrams (sort x) xs)
in
(x:listOfAnagrams):(groupByAnagrams listOfNonAnagrams)
Run Code Online (Sandbox Code Playgroud)
这个辅助函数接受一个排序的字符串sortedStr和一个字符串列表(字符串排序的原因是我不必每次迭代都对它进行排序).字符串列表分为两个列表; 一个由字符串组成的字符串,sortedStr另一个字符串由字符串组成.该函数返回由这两个列表组成的元组.
partitionByAnagrams :: String -> [String] -> ([String], [String])
partitionByAnagrams sortedStr [] = ([], [])
partitionByAnagrams sortedStr (x:xs)
| (sortedStr == (sort x)) = let (listOfAnagrams, listOfNonAnagrams) = (partitionByAnagrams sortedStr xs)
in
(x:listOfAnagrams, listOfNonAnagrams)
| otherwise = let (listOfAnagrams, listOfNonAnagrams) = (partitionByAnagrams sortedStr xs)
in
(listOfAnagrams, x:listOfNonAnagrams)
Run Code Online (Sandbox Code Playgroud)
这只是一个测试用例: …
这是一个Haskell函数,它接受一个数字n并返回第n个斐波纳契数.(我使用了索引方案,使得第0个数字为0,第1个数字为1,第2个数字为1,第3个数字为2,依此类推.)
fib :: (Integral a) => a -> a
fib 0 = 0
fib n = fibhelper n 0 1
fibhelper :: (Integral a) => a -> a -> a -> a
fibhelper 1 x y = y
fibhelper n x y = fibhelper (n-1) y (x+y)
Run Code Online (Sandbox Code Playgroud)
现在,假设为了效率,我想绕过Haskell的懒惰评估并强制评估更新的参数(例如使用$!运算符?)最优雅/惯用的方法是什么?
haskell tail-recursion pattern-matching fibonacci lazy-evaluation