This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn frac-pp [x] | |
(let [rat (if (rational? x) x (rationalize x)) | |
num (numerator rat) | |
den (denominator rat)] | |
(println num) | |
(println "-----") | |
(println den))) | |
(frac-pp 1.5) | |
(frac-pp (/ 3 2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn mkframe [] | |
(let [frame (java.awt.Frame.)] | |
(.setVisible frame true) | |
(.setSize frame (java.awt.Dimension. 512 512)) | |
(let [gfx (.getGraphics frame)] | |
(.drawString gfx (.. (java.util.Date.) toString) 160 256)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn xors | |
"Returns bitwise XORs" | |
[max-x max-y] | |
(for [x (range max-x) | |
y (range max-y)] | |
[x y (bit-xor x y)])) | |
(def frame (java.awt.Frame.)) | |
(.setVisible frame true) | |
(.setSize frame (java.awt.Dimension. 512 512)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(throw (Exception. "Oh noes!")) | |
(defn throw-catch [f] | |
(try | |
(f) | |
(catch ArithmeticException e "Are you bad at math?") | |
(catch Exception e (str "That didn't work!" e)) | |
(finally (println "returning...")))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn throw-catch [f] | |
[(try | |
(f) | |
(catch ArithmeticException e "No dividing by zero!") | |
(catch Exception e (str "You are so bad " (.getMessage e))) | |
(finally (println "returning... ")))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/Users/philipp/.rvm/rubies/ruby-1.9.2-p180/bin/ruby | |
# | |
# This file was generated by RubyGems. | |
# | |
# The application 'annotate-gff' is installed as part of a gem, and | |
# this file is here to facilitate running it. | |
# | |
require 'rubygems' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
params=$* | |
ruby_version=$(ruby -v) | |
echo $ruby_version | |
dir=$(dirname $0) | |
if [[ $ruby_version == jruby* ]]; | |
then | |
ruby "-J-Xmx2g" "${dir}/lib/annotate-gff.rb" ${params} | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JRUBY! | |
warning: -J-Xmx2g argument ignored (launched in same VM?) | |
Hello | |
Still there? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if RUBY_PLATFORM =~ /java/ | |
puts "JRUBY!" | |
command = "ruby -J-Xmx2g " + File.join(File.dirname(__FILE__), '..', 'lib/hello.rb') | |
system(command) | |
else | |
puts "MRI" | |
command = "ruby " + File.join(File.dirname(__FILE__), '..', 'lib/hello.rb') | |
system(command) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
echo $* | |
RUBY_VERSION=/usr/bin/env ruby -v | |
echo $RUBY_VERSION | |
if [[ $RUBY_VERSION == "jruby*" ]]; | |
then | |
echo "JRUBY\!" | |
else |