- Clojure, the core data structures aren't mutable
Clojure Data Structures
Clojure has two types of expressions atoms and collections
ATOMS
Atoms represent Primitive Types in other languages, like:
Numbers, Strings, Boolean, Nil, Symbols, Keywords
$ git init |
$ git add . |
l = "i am what i am" | |
# to integer | |
l.unpack('U*') # => [105, 32, 97, 109, 32, 119, 104, 97, 116, 32, 105, 32, 97, 109] | |
# to hex | |
l.unpack('H*') # => ["6920616d2077686174206920616d"] | |
# if you want the hex in array form then | |
l.unpack('U*').map{|i| i.to_s(16)} # => ["69", "20", "61", "6d", "20", "77", "68", "61", "74", "20", "69", "20", "61", "6d"] |
# in Gemfile | |
gem "fastercsv", :platforms => [:mri_18, :ruby_18] | |
# in app/config/environment.rb | |
require "csv" | |
unless !CSV.const_defined? :Reader | |
require "fastercsv" |
###In order to use ruby-debug with ruby-1.9.3 you need to download the following from http://rubyforge.org/frs/?group_id=8883 ### | |
linecache19-0.5.13.gem | |
ruby_core_source-0.1.5.gem | |
ruby-debug19-0.11.6.gem | |
ruby-debug-base19-0.11.26.gem | |
###then from the terminal run,### | |
gem install ruby_core_source-0.1.5.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0 |
1) PYTHON | |
2) CLOJURE | |
3) SCALA | |
4) HASKELL | |
5) Node.js |
Start of Heisenbug logging ====================================== | |
# Logfile created on 2013-10-27 21:17:25 +0530 by logger.rb/31641 | |
Started GET "/users/user_273" for 127.0.0.1 at 2013-10-27 21:17:25 +0530 | |
Processing by UsersController#show as HTML | |
Parameters: {"id"=>"user_273"} | |
Rendered shared/sidebar/_gravatar.haml (0.1ms) | |
Rendered shared/_pagination.haml (0.0ms) | |
Rendered updates/_list.html.haml (0.3ms) | |
Rendered users/show.haml within layouts/application (5.7ms) | |
Rendered shared/_head.html.haml (0.9ms) |
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. | |
/Users/manoj/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb | |
creating Makefile | |
Compiling v8 for x64 | |
Using python 2.7.6 | |
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 | |
Unable to find a compiler officially supported by v8. | |
It is recommended to use GCC v4.4 or higher |
Clojure has two types of expressions atoms and collections
Atoms represent Primitive Types in other languages, like:
Numbers, Strings, Boolean, Nil, Symbols, Keywords
;; eg: symbols in clojure, points to a verb or other values | |
;; when clojure evaluates a symbol it looks up that symbols meaning | |
inc | |
;; refer to symbols without evaluating its meaning | |
;; ' escapes a expression. Quote anything and get it back exactly | |
;; the same | |
'inc |