f#访问树的根元素(f# access root element of a tree)
我在F#中有一个规范树,即通过声明
type binaryTree = | Leaf | Node of binaryTree * float * binaryTree
然后使用递归函数来创建树
let rec makeTree tree element = match element, tree with | x, Leaf -> Node(Leaf,x,Leaf) | x, Node(l,y,r) -> Node(l,y, (makeTree r x))
这一切都很好。 现在我想对树进行排序,以便在每个节点上,节点的值小于其所有子节点的值。 我可以想象这样做。 但是,我想采用树的第一个元素。 也就是说,我想将树视为队列。 我在树上看到的唯一例子是使用高阶函数来对树做一些事情,但是当我已经对它进行排序时,这似乎是一种浪费。
如何访问此树的根节点?
I have a canonical tree in F#, i.e by declaring
type binaryTree = | Leaf | Node of binaryTree * float * binaryTree
and then using a recursive function to make the tree
let rec makeTree tree element = match element, tree with | x, Leaf -> Node(Leaf,x,Leaf) | x, Node(l,y,r) -> Node(l,y, (makeTree r x))
This is all fine. Now I want to sort the tree so that at each node, the value of the node is smaller than the value of all its children. I can imagine doing this. However, I want to then take the first element of the tree. That is, I want to treat the tree like a queue. The only examples I have seen with trees use higher-order functions to do something with the tree, but this seems like a waste when I have already sorted it.
How can I access the root node of this tree?
原文:https://stackoverflow.com/questions/5817777
最满意答案
您的问题可能与您的发送/接收大小以及JDB上面发布的Graph问题中的对象有关。 您可以将配置中的这些数字膨胀到目前可用的数据量,但是,当您最终来回传递非常大的响应时,这不是一个可行的长期解决方案。
我建议考虑从WCF服务流式传输您的序列化响应,这将允许您发送和接收长期无限量的数据。 此MSDN链接中概述了此过程: http : //msdn.microsoft.com/en-us/library/ms733742.aspx
不要让文章的长度吓到你,它只是给你关于为什么和如何的背景信息。 这个过程本身并不太复杂,无法理解并将解决您未来的问题。
〜VulgarBinary
Your issue is likely with your send / receive size as well as the objects in Graph issue that JDB posted above. You can inflate these numbers in your configuration to a point where it will work for the moment with the amount of data you currently have, however, this is not a viable long term solution when you might end up passing very large responses back and forth.
I would recommended looking into streaming your serialized response from the WCF service, which will allow you a limitless amount of data longer term to be sent and received. This process is outlined in this MSDN link: http://msdn.microsoft.com/en-us/library/ms733742.aspx
Don't let the length of the article scare you, it's just giving you background information on why and how. The process itself isn't too complicated to understand and will solve your problem going into the future.
~VulgarBinary
相关问答
更多-
更改以下内容 public List GetConsumer(string transformer, string account) 至 public List
GetConsumer(string transformer, string account) { 然后在您的移动项目上更新您的服务参考。 然后,您将能够执行以下操作: using(var service = new MyService()) //MyService is the name of your ser ... -
您可以将存储层实现为$ cacheFactory,并在配置阶段将其添加到$ httpProvider 。 来自文档: 启用缓存后,$ http将来自服务器的响应存储在指定的缓存中。 下次发出相同请求时,将从缓存提供响应,而不向服务器发送请求。 因此,如果使用以下方法提供自己的缓存实现: {object} info() - 返回缓存的id,size和选项。 {{*}} put({string} key, {*} value) - 将新的键值对放入缓存并返回它。 {{*}} get({string} key) ...
-
可以使用文档中更详细描述的maximumFileSizeToCacheInBytes配置参数来增加限制。 例如: { maximumFileSizeToCacheInBytes: 5000000, // ...other Workbox build configuration options... } The maximumFileSizeToCacheInBytes configuration parameter, described in more detail in the docs, ca ...
-
您可以在配置文件(例如,appsettings)中存储您的服务端点地址,在代码中您只更新主机名。 您的appsettings将包含net.tcp:// {0}:6666 / SomeService。 在创建客户端(代理)实例时 - 您将添加特定主机并传递此构建的地址。 就像是: 客户端上的app.config:
... -
您的问题可能与您的发送/接收大小以及JDB上面发布的Graph问题中的对象有关。 您可以将配置中的这些数字膨胀到目前可用的数据量,但是,当您最终来回传递非常大的响应时,这不是一个可行的长期解决方案。 我建议考虑从WCF服务流式传输您的序列化响应,这将允许您发送和接收长期无限量的数据。 此MSDN链接中概述了此过程: http : //msdn.microsoft.com/en-us/library/ms733742.aspx 不要让文章的长度吓到你,它只是给你关于为什么和如何的背景信息。 这个过程本身并不太 ...
-
好的,我找到了我要找的东西。 根据Microsoft提供的“WCF安全指南” ,在“代理注意事项”下声明: 代理注意事项 仅在需要时发布WCF服务元数据。 如果需要发布WCF服务元数据,请通过HTTPS协议发布它。 如果需要发布WCF服务元数据,请使用安全绑定发布它。 如果您关闭相互身份验证,请注意服务欺骗。 OK, I found what I was looking for. According to "WCF Security Guidelines" provided by Microsoft , u ...
-
您可以使用known types 。 这些也可以使用
部分在配置文件中定义(请参阅本文中的“ 添加已知类型的其他方法 ”)。 这就是说你可能想要定义一个基本数据契约类型,所有其他可能的数据契约将从中派生出来,让你的操作返回这个基础数据契约,而不是使用对象。 You could use known types. Those could also be defined in the config file using the IBar需要具体和DataContract。 WCF不是关于分布式对象,而是一种传输数据并使服务在这些数据上运行的方式。 您无法返回WCF中具有行为的对象。 IBar needs to be concrete and a DataContract. WCF isn't about distributed objects, but rather a way to transfer data and have services work on that data. You can't return an obj ...所以我不知道我是否理解你,但为了保持原样,请尝试使用: Listworker = new List (proxy.GetAllWorkers()); 要么 如果workertasks字段是引用类型变量,那么它可能发生,也许你提供对你没有接受的范围的引用 编辑:并且是Worker类DataContract? So I dont know if I understood you well, but for be siure please try use: List 你可以使用is_array($item->string)来检查你是否有一个数组然后适当地处理它。 根据您的代码,我认为这样的事情可能适合您。-
string)):
foreach($item->string as $subitem):
-
相关文章
更多- Securing Solr on Tomcat access using a user account
- EasyUI Tree与Datagrid联动
- struts2 + extjs + json + tree
- 飞利浦Tablet 7 PI3000 如何ROOT
- Becoming a data scientist
- Linux 忘记root密码解决方法
- ACCESS TOKEN
- java微信接口之——获取access_token
- [掌眼]微信支付测试返回:access_control:not_allow或system:access_denied
- 微信开发第四篇:获取access_token
最新问答
更多- 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
- 如何打破按钮上的生命周期循环(How to break do-while loop on button)
- C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
- 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
- 如何并排放置两个元件?(How to position two elements side by side?)
- 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
- 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
- Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
- 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
- 电脑高中毕业学习去哪里培训
- 电脑系统专业就业状况如何啊?
- IEnumerable
linq表达式(IEnumerable linq expressions) - 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
- Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
- 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
- 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
- 的?(The ? marks in emacs/haskell and ghc mode)
- 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
- 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
- 悬停时的图像转换(Image transition on hover)
- IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
- 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
- java分布式框架有哪些
- Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
- PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
- 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
- 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
- typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
- 武陟会计培训类的学校哪个好点?
- 从链接中删除文本修饰(Remove text decoration from links)