레이블이 Erlang인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Erlang인 게시물을 표시합니다. 모든 게시물 표시

2013년 4월 23일 화요일

erlang bench


1. Add concurix_runtime to your rebar.config file:
{concurix_runtime, ".*",
{git, "https://github.com/Concurix/cx_runtime.git"}}
2. Start the concurix_runtime system:
concurix_runtime:start()
3. Navigate to http://concurix.com/main/bench

http://www.erlang-factory.com/upload/presentations/747/ErlangConfTalk1v3final1.pdf

2013년 2월 7일 목요일

erlang 관련 글

erlang을 사용하는 업체들 목록
http://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why


http://blog.whatsapp.com/index.php/2012/01/1-million-is-so-2011/

http://blog.derekperez.com/post/41382405844/teach-protocols-not-languages

2013년 2월 6일 수요일

2012년 10월 22일 월요일

동일LAN상 다른 머신 접속방법

A머신  - 192.168.0.103
B머신 - 192.168.0.100

B나 A에서 
B 의 /etc/hosts 끝에 192.168.0.103 desktop

a@desktop> erl -sname a@desktop -setcookie abc
b@test> erl -sname b@desktop -setcookie abc

{badrpc,nodedown} -> host가 다른 경우 나옴.

Connection attempt from disallowed node -> cookie 값이 다른 경우 나옴.


2012년 7월 17일 화요일

erlang에서 when 구분에서 or 사용법


http://stackoverflow.com/questions/1110601/in-erlang-when-do-i-use-or-or

; => or  : F(A,B) when A=:=B ; A > 0- > 
, => and :  F(A,B) when A=:=B, A > 0- > 


---------------------------------------------
댓글보고 수정했습니다. whne -> when ^^;;



2012년 6월 15일 금요일

언어별 나머지


나머지 구하기
scheme : remainder

erlang : rem

clisp : rem

몫 구하기

erlang : / 실수형
           div 정수형

clisp  : 정수 / 정수 :  분수
           정수 / 실수 or 실수 / 정수 : 실수

2012년 4월 2일 월요일

project euler12


%%%-------------------------------------------------------------------
%%% @author jaejin <>
%%% @copyright (C) 2012, jaejin
%%% @doc
%%% The sequence of triangle numbers is generated by adding the natural numbers.%%%  So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:

%%% 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...

%%% Let us list the factors of the first seven triangle numbers:

%%  1: 1
%%  3: 1,3
%%  6: 1,2,3,6
%% 10: 1,2,5,10
%% 15: 1,3,5,15
%% 21: 1,3,7,21
%% 28: 1,2,4,7,14,28
%% We can see that 28 is the first triangle number to have over five divisors.

%% What is the value of the first triangle number to have over five hundred divisors?
%%% @end
%%% Created : 31 Jan 2012 by jaejin <>
%%%-------------------------------------------------------------------
-module(euler12).
-author(jaejin).
-compile(export_all).

trianglenumbers(N)->
    trianglenumbers(N,0).

trianglenumbers(N,Result) when N > 1 ->
    trianglenumbers(N-1,Result + N);
trianglenumbers(1,Result) ->
    Result +1.

divisors(N)->
    dict:fold(fun(_Key,Value,Sum)-> (Value+1) * Sum end,1, divisor_dict(N)).

divisor_dict(N)->
    divisor_dict(N,2,dict:new()).

divisor_dict(N,M,Dict) when N =:= M ->
    dictStore(Dict,M);
divisor_dict(N,M,Dict) when N rem M =:= 0 ->
    divisor_dict(N div M,M,dictStore(Dict,M));
divisor_dict(N,M,Dict) when N rem M =/= 0 ->
   divisor_dict(N,M+1,Dict).

dictStore(Dict,Key)->
    Is_key = dict:is_key(Key,Dict),
    if Is_key ->
            dict:store(Key,dict:fetch(Key,Dict)+1,Dict);
       true ->
            dict:store(Key,1,Dict)
    end.

run() ->
    run(7,28).

run(N,Result)->
   C =  divisors(Result),
%% %    io:format("Result => ~p ~n",[{Result,N,C}]),
%%     if C >= 200 ->
%%             N;
%%        C < 200 ->
%%             run(N+1,Result+N)
   end.


이걸로 했더니. 답이 안나온다. ㅡㅡ;;


안되서 자바로 했다.


import java.util.HashMap;

/**
 * Created by IntelliJ IDEA.
 * User: jaejinyun
 * Date: 12. 4. 2.
 * Time: 오후 11:11
 * To change this template use File | Settings | File Templates.
 */
public class Euler11 {

    public static int divisor(int n) {
        HashMap<Integer,Integer> divisor = new HashMap<Integer, Integer>();
        int find = 2;
        int m = n;
        System.out.println("find = "+find + " n = " + n + " m ="+m);
        while(find <= m) {
            System.out.println(find);
            if( m % find == 0) {
                m = m / find;
                if( divisor.get(find) != null ) {
                    divisor.put(find,divisor.get(find)+1);
                } else {
                    divisor.put(find,1);
                }
            } else {
                find++;
            }
        }

        int result =1;
        for(int value : divisor.values()) {
              result *= (value+1);
        }
        return result;
    }

    public static void find() {
        int n = 7;
        int result = 28;
        int divisorResult = 0;

        while(divisorResult <= 500)  {
             n++;
             result += n;
             divisorResult = divisor(result);

            System.out.println("n ="+n+" triagle num="+result + " divisor ="+divisorResult);
        }

    }

    public static void main(String[] args) {
        System.out.println("test");
        find();
    }
}



2012년 3월 6일 화요일

sockjs

sockjs 종류


  •  client lib
    • SockJS-client JavaScript client library
      • 웹소켓 같은 object을 SockJS라고 자바스크립트 lib로 제공
      • Websocket을 지원하지 않는 브라우저에서도 사용가능
  • Server lib


To Do




2012년 2월 20일 월요일

erlang에서 파일 읽기


  • 라인별로 읽기

    1> {ok, S} = file:open("data1.dat", read).
    {ok,<0.43.0>}
    2> io:get_line(S, '').
    "{person, \"joe\", \"armstrong\",\n"
    3> io:get_line(S, '').
    "\t[{occupation, programmer},\n"
    4> io:get_line(S, '').
    "\t {favoriteLanguage, erlang}]}.\n"
    5> io:get_line(S, '').
    "\n"
    6> io:get_line(S, '').
    "{cat, {name, \"zorro\"},\n"
    7> io:get_line(S, '').
    "
    {owner, \"joe\"}}.\n"
    8> io:get_line(S, '').
    eof
    9> file:close(S).

    •  

    2010년 8월 9일 월요일

    [sicp] 1.9

    1.9

    첫번째 : iterative

    a : counter

    b : product

    a가 1 감소할때마다 b는 1씩 증가해서 a가 0이 되면 b는 결과 출력

    [code] #lang scheme (define ( inc a ) (- a -1)) (define (dec a) (- a 1)) (define (+ a b) (if (= a 0) b (+ (dec a) (inc b)))) (+ 4 5) [/code]
    erlang 버젼
    [code] -module(iterative). -export([inc/1,dec/1,plus/2]). inc(A)->A+1. dec(A)->A-1. plus(0,B) -> B; plus(A,B)-> plus(dec(A),inc(B)). [/code]
    두번째 : recursive

    전형적인 재귀
    a가 1씩 감소할떄마다 재귀호출를 1번씩 해서 총 a가 감소만 만큼 재귀호출한 후에
    a만큼 다시 더하는 방식

    [code] #lang scheme (define ( inc a ) (- a -1)) (define (dec a) (- a 1)) (define (+ a b) (if (= a 0) b (inc (+ (dec a) b)))) (+ 4 5) [/code]