Map, reduce, and filter in Go ?

blov · · 1293 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><a href="https://www.reddit.com/r/golang/comments/1m25a1/map_reduce_and_filter_in_go/" rel="nofollow">This question as already been asked three years ago,</a> but I would like to know whether the situation has changed.</p> <p>Many proof of concepts and toy projects exist, but I&#39;m wondering whether something more solid is maintained.</p> <p>So far I found :</p> <ul> <li><a href="https://gobyexample.com/collection-functions" rel="nofollow">Go By Example : collection functions</a> <em>(very simple)</em></li> <li><a href="https://github.com/tobyhede/go-underscore" rel="nofollow">Go-Underscore</a> <em>(not maintained)</em></li> <li><a href="https://github.com/ahl5esoft/golang-underscore" rel="nofollow">Golang-Underscore</a> <em>(not maintained)</em></li> <li><a href="https://github.com/alioygur/godash" rel="nofollow">Godash</a> <em>(not maintained, <a href="https://www.reddit.com/r/golang/comments/49t47a/go_package_godash_a_utility_library_in_go/" rel="nofollow">was destroyed on this sub</a>)</em></li> <li><a href="https://github.com/robpike/filter" rel="nofollow">Filter</a> <em>(not maintained)</em></li> </ul> <hr/>**评论:**<br/><br/>clvrname: <pre><p>Check out <a href="https://github.com/chrislusf/glow" rel="nofollow">Glow</a> and <a href="https://github.com/chrislusf/gleam" rel="nofollow">gleam</a></p></pre>yellowiscool: <pre><p>Thanks. It seems a bit overkill for my usage, but it&#39;s definitely interesting to see alternatives to Apache Spark and similar in Go.</p></pre>mixedCase_: <pre><p>The situation is the same and will not change at the very least until Go 2 if generics are added or if they&#39;re (map/filter/reduce) special-cased into the language like the range keyword (very unlikely).</p></pre>yellowiscool: <pre><p>Could they add a standard library with more advanced and high level data containers? Being thread safe and supporting map/reduce/filter for example. C# provides that and it&#39;s very convenient. </p></pre>tv64738: <pre><p>&#34;Thread safe&#34; containers are typically the wrong thing. You want atomic <em>semantic actions</em>, for whatever the application logic is.</p> <p>For example: if key K is not in this set, allocate a new value with key K and add it. Trying to construct that from just atomic get/set is the wrong way around.</p></pre>mixedCase_: <pre><p>No, as Go libraries are written in Go and Go doesn&#39;t have generics, while C# does.</p></pre>thesnowmancometh: <pre><p>By the creator of Go himself: <a href="https://github.com/robpike/filter" rel="nofollow">https://github.com/robpike/filter</a> As he indicates, you shouldn&#39;t use it for professional code. Just use a for loop because not everyone has to understand functional operations. </p></pre>yellowiscool: <pre><p>Thanks. I saw it, but I want to write professional code and I think functional operations are sometimes more readable than for loops.</p></pre>faiface: <pre><p>Actually, that package is probably as production-ready as this kind of stuff can possibly get in Go.</p> <p>The reason that he does not recommend actually using it, is that this just doesn&#39;t fit in Go. One of the reasons being generics. Also, it can unexpectedly slow down your code, since Go doesn&#39;t do lazy evaluation.</p> <p>If you really want to use it, use the Rob Pike&#39;s package, it won&#39;t get much better.</p></pre>thesnowmancometh: <pre><p>How do you plan to do that with type safety?</p></pre>yellowiscool: <pre><p>Yeah, go is missing generics. </p></pre>itsmontoya: <pre><p>I wrote a simple linked list data store which offers map, filter, and reduce. Feel free to borrow any of the concepts used.</p> <p><a href="https://github.com/itsmontoya/linkedlist" rel="nofollow">Link</a> </p></pre>yellowiscool: <pre><p>Thanks, I will take a look. </p></pre>itsmontoya: <pre><p>For sure! If you have any questions feel free to ask.</p></pre>Redundancy_: <pre><p>Slightly different: <a href="https://github.com/Redundancy/fileMapReduce" rel="nofollow">https://github.com/Redundancy/fileMapReduce</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1293 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传