首页 \ 问答 \ 签名的“.NET”和“OCaml”格式(“.NET” and “OCaml” formatting of signatures)

签名的“.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
更新时间:2021-11-29 10:11

最满意答案

这是因为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 ...
  • 让我们看看默认的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和宅基地安装并添加了 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/'

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。