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 to 10)foreach( | |
x => (1 to 10)foreach( | |
y =>if(y !=10) print(x * y+ "\t") else println(x *y + "\t") | |
) | |
) |
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
def box(x:Int)(y: Int)(z:Int)= | |
x * y * z | |
println(box(1)(2)(3)) | |
val boxWithX = box(1)_ | |
println(boxWithX(2)(2)) | |
val boxWithXY =boxWithX(2)(_:Int) | |
// val boxWithXY =boxWithX(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
(1 to 100).foreach{ i => | |
printf("%d",i) | |
if(i % 3 == 0) printf("Fizz") | |
if(i % 5 == 0) printf("Buzz") | |
printf(" ")} | |
println |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
) | |
func swap(a int,b int)(int,int){ | |
if a > b { | |
return b, a | |
}else { |
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
#include<stdio.h> | |
typedef int (*func)(int x, int y); | |
int cat(int, int); | |
int dog(int, int); | |
int bird(int, int); | |
int | |
main() | |
{ |
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
require 'pp' | |
# encoding: utf-8 | |
# Build description. | |
# basic build file for mruby | |
p MRUBY_ROOT = File.dirname(File.expand_path(__FILE__)) | |
p MRUBY_BUILD_HOST_IS_CYGWIN = RUBY_PLATFORM.include?('cygwin') | |
# load build systems | |
#p load "#{MRUBY_ROOT}/tasks/ruby_ext.rake" | |
#p load "#{MRUBY_ROOT}/tasks/mruby_build.rake" |
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
--zipTwo :: ( a -> b -> c ) -> [a] -> [b] -> [c] | |
--zipTwo _ [] _ = [] | |
--zipTwo _ _ [] = [] | |
--zipTwo f (x:xs) (y:ys) = f x y : f xs ys | |
--分かった 再帰を使っているのに引数にとった関数を使おうとしているから | |
-- 上手くいかなかった | |
zipTwo :: (a -> b -> c) -> [a] -> [b] -> [c] | |
zipTwo f [] _ = [] | |
zipTwo f _ [] = [] |
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
import scala.io._ | |
object FileUtils { | |
def main( args: Array[String] ) : Unit = { | |
Source.fromFile(args(0) ).foreach{ | |
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
#include<stdio.h> | |
#include<stdlib.h> | |
#include<math.h> | |
#define LEN 1000 | |
#define PRIME int | |
struct list{ | |
struct list *next; |
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
#include<stdio.h> | |
#include<stdlib.h> | |
double newton(double c) | |
{ | |
double x; | |
int i; | |
x = ( c + c / c ) / 2; |
OlderNewer