约束/保护OCaml中的类型(Constraint/Guard a type in OCaml)
给定是一种用于构造二叉树的类型:
type tree = Leaf of int | Node of int * tree * tree
现在假设我们想通过类型表示二叉树包含一个元素为零的节点,即,我想表达以下形式的东西:
let rec p x = match x with | Leaf(y) -> y = 0 | Node(y,l,r) -> y = 0 || (p l) || (p r) type zerotree = ZeroTree of t:tree where p(t)
这意味着,每当我有一个ZeroTree类型的树,那么我可以确定树包含一个元素为零的节点,即谓词
p
成立。在OCaml中有类似的东西吗?
Given is a type in order to construct a binary tree:
type tree = Leaf of int | Node of int * tree * tree
Now assume we want to express via types that a binary tree contains a node with an element zero, i.e., I would like to express something of the following form:
let rec p x = match x with | Leaf(y) -> y = 0 | Node(y,l,r) -> y = 0 || (p l) || (p r) type zerotree = ZeroTree of t:tree where p(t)
That means, whenever I have a tree of type ZeroTree, then I can be sure that the tree contains a node with an element zero, i.e., the predicate
p
holds.Is something like that expressible in OCaml?
原文:
最满意答案
您必须在
minSelectedTime
中设置minSelectedTime
以在股票图表中实现相同的行为。 请注意,这也将阻止直接拖动滑块时滚动条缩小到较小的时间范围:var chart = AmCharts.makeChart("chartdiv", { panelsSettings: { mouseWheelZoomEnabled: false, minSelectedTime: 4.32e+9, mouseWheelScrollEnabled: true }, // ... });
You have to set
minSelectedTime
in thepanelsSettings
to achieve the same behavior in a stock chart. Note that this will also prevent the scrollbar from zooming to a smaller time frame when dragging the sliders directly:var chart = AmCharts.makeChart("chartdiv", { panelsSettings: { mouseWheelZoomEnabled: false, minSelectedTime: 4.32e+9, mouseWheelScrollEnabled: true }, // ... });
相关问答
更多-
当用户缩放或取消窗口时,窗口将向其委托发送windowWillUseStandardFrame:defaultFrame: message 。 第一个参数是被缩放的窗口; 第二个是默认标准框架,它是屏幕的大小。 您返回首选(“标准”)框架。 如果窗口的框架已经等于您返回的标准框架,则窗口将取消缩放到用户的首选大小(通过手动调整大小来表示)。 否则,窗口将缩放到标准框架。 对此的推论是,如果标准帧在缩放之间变化,则窗口将在第一次缩放并且将再次缩放(到新标准帧)第二次。 如果内容的大小在缩放之间发生变化,则可能 ...
-
Microsoft Edge:window.open仅在首次尝试时才能正常工作(Microsoft Edge: window.open only works correctly at first attempt)[2022-04-20]
以上答案只是部分正确。 当您第二次打开窗口时,Build 10240会更正空白框。 但是,新的弹出窗口仍然会在50%的时间内打开主浏览器窗口。 即他们不会自动获得焦点。 您只知道它们在那里,因为任务栏上的Edge图标闪烁。 No longer an issue, this is fixed in windows 10 preview build 10240 -
你检查的变量是否是你的“球超出界限”(所以评论,谢谢你!)永远不会改变。 例如, btc在循环外部的开头分配一次,然后再也不分配。 我想你应该在(等)变化时改变它们。 当然,这不是一种好的编码风格。 但试图解决这个问题会打开一大堆蠕虫;-) 编辑:此外,您应该取消速度变量而不是位置变量,即bym而不是by : bym = bym * -1 。 在解决了这两个问题之后,我的球始终在窗户边缘反弹。 但踏板仍然没有影响: # check if ball is out of bounds btc = ...
-
我使用问题步骤记录器记录了这些步骤,并发现在打印表格内容之前每当触发鼠标拖放时,打印对话框就会卡在子窗口内。 为此,我使用以下脚本禁用了鼠标拖放事件: $("body").on("dragstart", function () { return false; }); $("body").on("drop", function () { return false; }); 对于打印内容后未关闭的子窗口,我将window.close()放在子窗口的onblur事件上:IE中不支持 window.pageXOffset属性(至少是7和8)。 试试$(window).offset().left而不是: jQuery(document).ready(function(){ jQuery("#nav>ul>li").each(function() { pos = jQuery(this).offset(); if(pos.left + 100 > jQuery(window).width()+jQuery(window).offset() ...
捏放大mapboxgl在整个铬窗口中放大。(Pinch to zoom on mapboxgl zooms in entire chrome window. How to prevent this?)[2023-09-09]
在开发Windows10自助服务终端的mapbox应用程序时,我遇到了同样的问题。 这可以解决我指定的触摸操作,因为没有mapbox容器div。 #map{ touch-action:none; } I had the same issue when developing mapbox app for a windows10 kiosk. This can be fixed my specifying touch-action as none for mapbox container div. # ...MS Edge有一个window.chrome对象??(MS Edge has a window.chrome object?? Breaks browser detection)[2022-02-14]
“你应该检查功能而不是浏览器” 像一个从未遇到过多个浏览器中存在的功能但在其出现的所有浏览器中无法运行或功能相同的人。 我自己最近的一个案例,我有一个小功能,在所有浏览器中工作至少12年,因为在Chrome存在之前。 该函数只会触发在客户端操作系统上注册的自定义URL以运行外部处理程序。 因此,它只是在子_blank窗口中启动自定义URL并立即关闭该子窗口。 function foo(stuff,otherstuff) { t = window.open("myproto://"+stuff,"_bla ...沿左边缘的Vim窗口填充(Vim window padding along left edge)[2023-11-25]
我自己没有看到这个问题,但这可能是因为所有文本都有左边缘,因为我显示行号。 也许这是你的选择。 :set number I haven't seen that problem myself, but that's probably because all text already has a margin from the left side because I display line numbers. Perhaps that's an option for you. :set numberes6 arrow函数,更多细节https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions 和类https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes es6 arrow function, for more detail https://developer.mozilla.org/en/docs/Web/ ...您必须在minSelectedTime中设置minSelectedTime以在股票图表中实现相同的行为。 请注意,这也将阻止直接拖动滑块时滚动条缩小到较小的时间范围: var chart = AmCharts.makeChart("chartdiv", { panelsSettings: { mouseWheelZoomEnabled: false, minSelectedTime: 4.32e+9, mouseWheelScrollEnabled: true }, / ...相关文章
更多- ServletOutputStream cannot be resolved to a type
- HTTP Content-Type 内容类型详解
- maven项目使用SOLR时报 previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest" 错的解决方法
- HTML 超链接(a标签、锚)
- 按钮样式
- Becoming a data scientist
- Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years
- Solr: a custom Search RequestHandler
- Spring Data: a new perspective of data operations
- Create a Bootable MicroSD Card
最新问答
更多- 获取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的基本操作命令。。。