Recipe 534162: An erlang Port in Python erlang has two built-in interoperability mechanisms. One is distributed erlang nodes and the other one is ports. Ports provide the basic erlang mechanism for communication with the external world. They provide a byte-oriented interface to an external program. When a port has been created, erlang can communicate with it by sending and receiving lists of...
by pascal4123 - Erlang - 2009-07-23 00:55:18 阅读(2094) 回复(0)
erlang下的io:format 换行打印"~n" io:format("你好~n世界"). 字符替换"~w" 直接替换,"~-15w"代表输出15个字符,不够的空格补 io:format("~-15w ~w", [test1, test2]). erlang下的列表数组与递归调用 erlang的“数组” 假设 [E1, E2 | R] = [1,2,3,4,5,6,7]. %注意其中的"|",带有分割的意思 结果 E1=1 E2=2 R=[3,4,5,6,7] 根据此判断字符长度: -module(tut). -export([len/1]). len([]) ->0; ...
Data = Req:parse_post(), Uid = list_to_binary(proplists:get_value("uid", Data)), %调试打印出来的是74 Uid2 = put(74,111), Topid = get(Uid), %undefined Topid2 = get(74), %输出111 为什么Topid = get(Uid), %undefined 这句得不到111呢??
[code] -module(echo). -export([start/0, loop/0,while/2]). start() -> spawn(echo, loop, []). loop() -> receive {From, Message} -> From ! Message, while(Message,10), loop() end. while(M,0)-> {over,M}; while(M,Count)-> io:format("this outputs for: ~w~n", [M]), while(M,Count-1). [/code] 并发运行: Id = echo:start(),Id2 = echo:start(). Id ! {self(), h...
以前我们用python做的一个演示产品, 以python -m CGIHTTPServer启动服务器后, cgi-bin 目录下的脚本文件根据程序员的喜好, 可以用python, scala开发: python脚本要加个 #!/usr/bin/python scala脚本要加个 #!/bin/sh exec scala "$0" "$@" !# 那能否用erlang开发CGI脚本呢? 答案是肯定的,因为eralng提供了escrip可以直接运行erlang代码. 用如下代码测试时, python却报CGI script exit status 0x7f00 ?! #!/usr/local/bin/...
-module(hello). -export([hello_world/0]). hello_world()-> io:format("Hello World ~n"). ----------------------------------------------------------------------- And Executing: hello:hello_world().
[quote]What's all this fuss about erlang? 原文: http://www.pragprog.com/articles/erlang 作者: Joe Armstrong 译者:许式伟 朱照远 没人可以预言未来,但我却打算做一些有依据的推测。 让我们假设 Intel 是正确的,而且 Keifer 项目会获得成功。如果是这样,那么 32 核的处理器在 2009/2010 年就将会出现在市场上。 这毫不奇怪, Sun 已经制造出了 Niagara ,它拥有 8 个核,每个核运行 4 个超线程(这相当于 32 个核)。...
下载源码: svn checkout http://erlang-mysql-driver.googlecode.com/svn/trunk/ erlang-mysql-driver-read-only 下载完后命名目录为"mysql",进入mysql/src目录对其下的文件全部进行编译; 建立mysql/ebin目录,把编译好的.beam文件拷贝到ebin中 复制mysql目录到erlang/lib目录下。 启动erlang sehll环境 #erl 连接mysql: 1>mysql:start_link(p1, "localhost", "root", "password", "test"). mysql_conn:620: greeting vers...
到这边下载erlydtl: http://code.google.com/p/erlydtl/ 解压后拷贝 erlydtl 目录到 erlang/lib 底下,然后 $ make $ erl -make 既安装完成。 任意目录下创建以下文件 创建文件:test.erl [code] -module(test). -export([run/0]). run()-> erlydtl:compile("tpl.htm", welcome_template), welcome_template:render([ {name, "Johnny"} ]). [/code] 创建模板文件 tpl.htm [code] Welcome back, {{...