签名的“.NET”和“OCaml”格式(“.NET” and “OCaml” formatting of signatures)
F#允许签名的“.NET”和“OCaml”格式。 当您养成使用一种风格的习惯,然后找到无法正确格式化所需签名的情况时,这可能会令人困惑。 考虑一下这个代码,它需要一个灵活的类型作为输入到foo的函数的输出:
let foo n (bar: int -> #seq<'a>) = (fun () -> Vector.ofSeq (bar n)) let foobar n = Array.ofSeq([1..n]) let x = foo 10 foobar
我无法弄清楚如何用OCaml格式表达#seq <'a>。 可能吗?
F# allows ".NET" and "OCaml" formatting of signatures. This can be confusing when you fall into the habit of using one style, and then find a situation where you cannot properly format the signature you need. Consider this code, which requires a flexible type as the output of the function input to foo:
let foo n (bar: int -> #seq<'a>) = (fun () -> Vector.ofSeq (bar n)) let foobar n = Array.ofSeq([1..n]) let x = foo 10 foobar
I could not figure out how to express #seq<'a> in OCaml format. Is it possible?
原文:https://stackoverflow.com/questions/10957700
最满意答案
这是因为javascript认为你想逃避一些事情。 所以你所要做的就是逃避反斜杠。 addslashes可以解决这个问题:
var storagePath = "<?php echo addslashes(storage_path()); ?>"; console.log('StoragePath ',storagePath);
This is because javascript thinks you want to escape something. So all you have to do, is escape the backslashes. addslashes will do the trick:
var storagePath = "<?php echo addslashes(storage_path()); ?>"; console.log('StoragePath ',storagePath);
相关问答
更多-
它实际上并不疯狂。 存储路径是可配置的,因此,如果Laravel将其存储在数据库中,但是将其更改为行,则会出现问题。 当您尝试在刀片模板中显示文件时,您可以简单地添加storage_path($file) 。 这会自动在文件名之前应用正确的存储路径,并且应该找到您的文件所在的位置。 告诉我,如果这有帮助/工作 it's not actually crazy. The storage path is configurable, therefore if Laravel were to store it in ...
-
如何使用storage_path()在laravel 4中查看图像(How to use storage_path() to view an image in laravel 4)[2022-10-21]
让我们看看默认的L4应用程序结构: 应用//包含受限的服务器端应用程序数据 app / storage // L4和自定义函数用于存储数据的可写目录(即日志文件,...) public //此目录可供客户访问 如果我是你,我会直接将文件上传到公共目录: 在此存储图像:public_path()。 'IMG / filename.jpg' 在数据库中保存'img / filename.jpg' 使用url生成图片网址('img / filename.jpg')=> http://www.your-domain ... -
使用内置的String方法replaceAll ,使用正则表达式"/+" ,用一个斜杠替换一个或多个斜杠: path = path.replaceAll("/+", "/"); Use the built-in String method replaceAll, with a regular expression "/+", replacing one or more slashes with one slash: path = path.replaceAll("/+", "/");
-
优雅的解决方 使用preg_replace您可以使用一行代码获取该代码: preg_replace('#/+#','/',$str); 模式/+将匹配正向/一次或多次,并将用单个/替换它。 不太优雅的解决方案 当然还有其他方法可以实现这一点,例如使用while循环。 while( strpos($path, '//') !== false ) { $path = str_replace('//','/',$path); } 这将调用str_replace直到所有出现的//被替换。 如果您想牺牲可读 ...
-
你必须使用getter方法 $image->getPathname() Symfony类从SplFileInfo扩展。 你可以在php.net上找到它所有方法的参考 You have to use the getter method $image->getPathname() The Symfony class extends from SplFileInfo. You can find the reference to all its methods on php.net
-
对于Laravel 5.3 我遇到了同样的问题,我搜索了同样的事情,但我最终编写了一个代码来手动从以前的URL中提取路径。 因此,我认为Laravel(直到5.3)没有提供这样的方法来获取前一个URL的路径。 For Laravel 5.3 I've gone through same problem and I had searched for the same thing but i end up writing a code to manually extract path from previous ...
-
这是因为javascript认为你想逃避一些事情。 所以你所要做的就是逃避反斜杠。 addslashes可以解决这个问题: var storagePath = ""; console.log('StoragePath ',storagePath); This is because javascript thinks you want to escape something. So all you have to do, is ...
-
Path.Combine不用于创建文件名或构建URL。 您应该首先构建文件名,然后使用Uri构建您的URL。 就像是 string avatarFilePath = "~/_images/avatar/"; string userId = 53da95a1-cc48-42d0-9a00-167f47ce5933"; string avatarFileExt = ".png"; string fileName = String.Format("{0}{1}", userId, avatarFileExt); ...
-
未定义的Laravel路径调用(Undefined Laravel path calls)[2022-11-16]
我做了一个干净的laravel和宅基地安装并添加了 welcome.blade.php来到welcome.blade.php并且它有效。 storage_path函数位于/vendor/laravel/framework/src/Illuminate/Foundatio ... -
从字符串中删除storage_path函数以将绝对路径放入... 'path' => '/var/www/blah/' Remove the storage_path function from the string to put an absolute path in... 'path' => '/var/www/blah/'