Javascript Developer Struggling with Recursion in Go

agolangf · · 382 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey Gophers! I&#39;m a Javascript developer by trade who decided to give Go a spin. As a learning exercise I decided to port a function in one of my node projects, but can&#39;t get it working for the life of me. The function&#39;s purpose is to display all of the valid english words that can be made from the letters present in a different word (I&#39;m building a multiplayer version of <a href="http://zone.msn.com/gameplayer/gameplayer.aspx?game=texttwist" rel="nofollow">Text Twist</a>). For example, findAllWords(&#34;dances&#34;) would return [&#39;can&#39;,&#39;scan&#39;,&#39;dance&#39;,&#39;dances&#39;,etc...]. I&#39;ve achieved this by recursing on a trie built from an English word list. </p> <p><a href="https://gist.github.com/wmain/7f39611f1b82c179e92a4a9c04808f91" rel="nofollow">Here is the function&#39;s implementation in Javascript</a> and <a href="https://gist.github.com/wmain/99ae79d2d4e64e56a24757b20676f62e" rel="nofollow">here&#39;s my attempt at replicating it in Go</a> (using <a href="https://github.com/derekparker/trie" rel="nofollow">this</a> trie implementation).</p> <p>Would love to know why this is failing, how I can get it working, and any conventions I&#39;m abusing/not making use of. Thanks!</p> <hr/>**评论:**<br/><br/>alpabet: <pre><p>in your go file, I think line 8 should just be &#39;continue&#39;, a return would stop the function and not continue the loop where your js implementation goes to the next iteration.</p></pre>bonekeeper: <pre><p>Out of curiosity, can you upload the full wordlist you are using somewhere? I need an English wordlist for a project.</p></pre>

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

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