选择用于学习数据结构和算法的编程语言[关闭](Choice of programming language for learning data structures and algorithms [closed])
建议您使用哪种编程语言 来了解 数据结构和算法 ?
考虑到以下几点:
- 个人经验
- 语言功能(指针,OO等)
- 适用于学习DS&A概念
我问,因为有一些书是编程语言 - 不可知(从数学角度写,并使用伪代码)。 如果我从其中的一个学习,我想选择一种编程语言来编写和运行算法。
然后,还有其他书籍介绍DS&A概念,并以特定的编程方式编写的例子,我也希望对这些算法进行编码,从而在一定程度上,语言也选择了这本书。
无论如何,我必须选择一种语言,我宁愿坚持一个语言。 放弃个人语言偏好,哪一个最适合这个目的?
Which programming language would you recommend to learn about data structures and algorithms in?
Considering the following:
- Personal experience
- Language features (pointers, OO, etc)
- Suitability for learning DS & A concepts
I ask because there are some books out there that are programming language-agnostic (written from a Mathematical perspective, and use pseudocode). If I learn from one of these, I would like to choose a programming language to code and run the algorithms in.
Then, there are other books which introduce DS & A concepts with examples written in a particular programming laguage - and I would like to code these algorithms as well - thus, to a certain extent, the language picks the book too.
Either way, I have to pick a language, and I would prefer to stick to one throughout. Setting aside personal language preferences, which one is best for this purpose?
原文:https://stackoverflow.com/questions/2657504
最满意答案
安卓Kouznetsov的答案没有为我使用Ruby 1.9.3。 ruby-debug gem似乎不支持Ruby 1.9。 我不得不使用调试器gem: https : //github.com/cldwalker/debugger 。
- 将gem'debugger
gem 'debugger'
添加到我的Gemfile的开发组。- 运行
bundle
- 添加
require 'debugger'
到我的耙子任务的顶部。- 添加一个调用
debugger
,我想在我的耙子任务中断点。- 通常从命令行运行rake任务,例如:
rake my:task
。Andrey Kouznetsov's answer didn't work for me using Ruby 1.9.3. The ruby-debug gem doesn't seem to support Ruby 1.9. I had to use the debugger gem: https://github.com/cldwalker/debugger.
- Add
gem 'debugger'
to my Gemfile's development group.- Run
bundle
.- Add
require 'debugger'
to the top of my rake task.- Add a call to
debugger
where I wanted a breakpoint in my rake task.- Run the rake task normally from the command line, e.g.:
rake my:task
.
相关问答
更多-
安卓Kouznetsov的答案没有为我使用Ruby 1.9.3。 ruby-debug gem似乎不支持Ruby 1.9。 我不得不使用调试器gem: https : //github.com/cldwalker/debugger 。 将gem'debugger gem 'debugger'添加到我的Gemfile的开发组。 运行bundle 添加require 'debugger'到我的耙子任务的顶部。 添加一个调用debugger ,我想在我的耙子任务中断点。 通常从命令行运行rake任务,例如: ra ...
-
如何列出所有Rails 3耙任务?(How to list all Rails 3 rake tasks? rake -T seems incomplete [duplicate])[2023-11-24]
我发现为什么是rake db:migrate:reset没有列在rake -T中? (感谢@Beerlington的链接), rake -P列出所有的任务,这是我正在寻找。 I found at Why is rake db:migrate:reset not listed in rake -T? (thanks @Beerlington for the link) that rake -P lists all tasks, which is what I was looking for. -
Ruby on Rails和Rake问题:未初始化的常数Rake :: DSL(Ruby on Rails and Rake problems: uninitialized constant Rake::DSL)[2023-06-21]
DHH的一个推文 。 Rake .9.0打破了Rails和其他几件事情,你需要: gem "rake", "0.8.7" 在你的宝石文件。 A tweet from DHH earlier. Rake .9.0 breaks Rails and several other things, you need to: gem "rake", "0.8.7" in your Gemfile. -
我不太确定,但我猜你应该能做到: if Rails.env.development? or Rails.env.test? namespace :clear_data do desc 'clear time slots' task :clear_time_slots, [:post_id] => :environment do |_, args| TimeSlot.where('health_post_id > ?', args[:post_id]).destroy_all end ...
-
如果我将gem'rdoc'添加到我的gem文件中,错误似乎就消失了。 我不确定为什么这会有任何区别,因为它已经是另一个宝石的依赖 The error seems to go away if I add gem 'rdoc' to my gem file. I am not sure why this makes any difference, because it was already a dependency of another gem
-
调试耙子任务(Debugging rake tasks)[2021-04-06]
尝试运行 e my_var 如果默认情况下未设置自动评估,则必须在任何评估表达式前加上e。 顺便说一下,要设置自动更新,请在~/.rdebugrc放入以下行: set autoeval 这样做后,任何不被调试器识别的命令都将被视为尝试评估en表达式,因此您只需输入变量名称即可获取其值。 Try to run e my_var If autoeval isn't set by default, you have to prefix any evaluation expression with e. By ... -
我可以通过执行以下操作来调试迁移 将ruby-debug添加到Gemfile gem 'ruby-debug19' 在迁移中,添加require 'ruby-debug'并在要停止的行中执行debugger 。 例如 require 'ruby-debug' class CreatePeople < ActiveRecord::Migration def self.up debugger create_table :people do |t| t.string :nam ...
-
在Heroku中扩展ruby应用程序的Rake任务(非rails)?(Rake tasks for scaling ruby apps in Heroku (non-rails)?)[2021-09-03]
task :scale_down do heroku = Heroku::API.new(api_key: ENV['HEROKU_API_KEY']) heroku.post_ps_scale(ENV['APP_NAME'], 'worker', 0) end 这会将应用程序缩小到0.可能要将该数字分配给配置变量.. task :scale_down do heroku = Heroku::API.new(api_key: ENV['HEROKU_API_KEY']) heroku.po ... -
如果这是您的第一次体验,我建议从Rails 2.3.8开始。 有很多教程和更广泛的支持; 3.0是相当新鲜的几个主要变化。 无论如何,你最终都能从2.3.8升级到3.0.0。 I would recommend starting with Rails 2.3.8 if this is your first experience. There are many tutorials and wider support; 3.0 is fairly fresh with several major changes ...
-
尝试添加环境,这将具有加载rails应用程序的效果。 task :scrape_info => :environment do ... end Try adding the environment, this will have the effect of loading your rails app. task :scrape_info => :environment do ... end