This file contains 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
;;;convert all the xsl files to csv files in one directory | |
;get all the file names in one directory | |
(def directory (clojure.java.io/file "C:/Users/echo/Dropbox/7000/data-sets")) | |
(def files (file-seq directory)) | |
(def filestr (map str files)) | |
;find all the xls files in the directory | |
(def xlsfiles (filter #(re-find #".xls" %) filestr)) | |
;clojure.string/replace | |
(defn xsl2csv [x] (save (read-xls x) (clojure.string/replace x #"xls" "csv"))) | |
;convert all the xls file to csv files |
This file contains 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
use Modern::Perl; | |
# my (a, b, c) = 1, 2, 3 | |
my $a=2; | |
my $b=3; | |
my $c=4; | |
say ($a, $b, $c); | |
sub test { | |
# my $c=0; | |
say $a; #2 |
This file contains 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
a, b, c = (1, 2, 3) | |
print(a, b, c) | |
def test(): | |
print(a) | |
print(b) | |
print(c) # (A) | |
c=1 # (B) | |
test() |
This file contains 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/perl | |
use 5.010; | |
use strict; | |
use warnings; | |
use autodie; | |
use Path::Class; | |
#use Simple::IO; | |
my $dir = dir("C:\\Users\\echo\\Dropbox\\bioinfo"); # /tmp | |
my $file = $dir->file("scope.pl"); |
This file contains 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
(ns playground.core) | |
;;http://www.reddit.com/r/dailyprogrammer/comments/x0v3e/7232012_challenge_80_easy_anagrams/ | |
(defn anagrams? [x y] | |
(and (= (sort x) (sort y)) | |
(not= x y))) | |
(defn anagrams [x] | |
(filter #(anagrams? (.toLowerCase x) %) dict)) | |
(def dict (clojure.string/split-lines |
This file contains 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
# 1+2+3+..+n | |
sub sum_natural($n) { | |
my ($total,$k)=0,1; | |
while $k<=$n { | |
$total=$total+$k; | |
$k=$k+1; | |
} | |
return $total; | |
} |
This file contains 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
sub <sum_name>($n) { | |
my ($total,$k)=0,1; | |
while $k<=$n { | |
$total=$total+<term>; | |
$k=<suc>; | |
} | |
return $total; | |
} |
This file contains 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
sub sum($n,&term,&suc) { | |
my ($total,$k)=0,1; | |
while $k<=$n { | |
$total=$total+term($k); | |
$k=suc($k); | |
} | |
return $total; | |
} |
This file contains 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
sub successor($k){ | |
$k+1; | |
} | |
sub cube($k) { | |
$k**3; | |
} | |
This file contains 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
sub successor($k){ | |
$k+1; | |
} | |
sub natural($k) { | |
$k; | |
} | |
sub pi($k) { | |
8/($k*($k+2)); |