Project Euler #3 in Erlang

I am trying to code Project Euler #3 in Erlang: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Here is my code: -module(problem_3). -compile(export_all). start()-> problem_3(600851475143, 2). problem_3(Num, F) when Num > 1 -> case Num rem F of 0 -> problem_3(Num / F, F); 1 -> problem

Erlang项目Euler#3

我想在Erlang中编写Project Euler#3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? 这是我的代码: -module(problem_3). -compile(export_all). start()-> problem_3(600851475143, 2). problem_3(Num, F) when Num > 1 -> case Num rem F of 0 -> problem_3(Num / F, F); 1 -> problem_3(Num, F + 1

Erlang vs OCaml (best niche to fit)

Hi I'd like to pick up one FP language (it's always a pain when you work in a position that does not require you learn much), and after doing some research, I felt Erlang and OCaml are the two that I'd really like to get my feet wet for the following reasons: 1) I work mainly on high-availability web server back-end system in C++. I heard Erlang is a great fix in scalability and fa

Erlang vs OCaml(最适合合适的位置)

嗨,我想选择一种FP语言(当你在一个不需要你学习的职位上工作时总是很痛苦),并且在做了一些研究之后,我觉得Erlang和OCaml是我真的喜欢弄湿我的脚,原因如下: 1)我主要在C ++中使用高可用性Web雅博国际顶级后端系统。 我听说Erlang在可扩展性和容错性方面是一个很好的解决方案。 虽然我不认为我现在的公司会在Erlang有任何项目,但我觉得Erlang可能是我长期职业发展的良好语言。 2)我有一个非常擅长OCaml的同事,我的意思

How do I get dialyzer to ignore certain unexported functions?

I'm using lager to do my logging; it has a parser transform which converts lager:warn/1 , etc. functions into lager:trace... functions. dialyzer doesn't process the parser transform, so it warns with Call to missing or unexported function lager:warn/1 . How do I tell it that this function does exist, and not to warn about it? 最好的办法是让dialyzer查看你的编译束文件,只要在编译代码

如何让透析器忽略某些未导出的功能?

我正在使用啤酒做我的日志记录; 它有一个解析器转换,将lager:warn/1等函数转换为lager:trace...函数。 透析器不处理解析器转换,所以它会通过Call to missing or unexported function lager:warn/1 。 我如何告诉它这个函数确实存在,而不是警告它? 最好的办法是让dialyzer查看你的编译束文件,只要在编译代码时应用解析变换,并且在你的.plt文件中包含lager就可以了 通过检查meck项目的Makefile中关于透析器的工作,找

Understanding what this Erlang Code is?

Not at all familiar with Erlang, but am trying to interpret what this code does? Below is my understanding about the code. Any help will be useful. I am looking at the tutorials but the passing values are confusing in this case. example- convert_list_to_k([{Name, {l, Weight}} | Rest]) //{1,Weight} <- This one And how is the value returned in convert_list_to_k ? let's say for this

了解这个Erlang代码是什么?

根本不熟悉Erlang,但我试图解释这段代码的作用? 以下是我对代码的理解。 任何帮助都是有用的。 我在看教程,但传递的值在这种情况下令人困惑。 example_ convert_list_to_k([{Name, {l, Weight}} | Rest]) //{1,Weight} <- This one 那么在convert_list_to_k返回的值如何? 让我们来说说这个功能块 convert_list_to_k([{Name, {l, Weight}} | Rest]) -> Converted_Object = {Name, {k, Weight / 0.4535923

Erlang queue inconsistent behaviour

雅博官网在线注册雅博体育锁定账户雅博国际顶级 There are differences in internal representation of the queues depending on: either it was created using queue:from_list() function or using queue:new() function and them populating with elements. Simple Code: L = [1,2,3], Q = queue:from_list(L), % convert it to Queue. L2 = queue:to_list(Q), % convert back to list. QL2 = queue:from_list(L2), % And create queue representation true = Q

Erlang队列行为不一致

队列的内部表示有所不同,具体取决于: 它是使用queue:from_list()函数创建的 或者使用queue:new()函数并使用它们填充元素。 简单代码: L = [1,2,3], Q = queue:from_list(L), % convert it to Queue. L2 = queue:to_list(Q), % convert back to list. QL2 = queue:from_list(L2), % And create queue representation true = Q =:= QL2. 到目前为止,一切都很好, Q看起来像: {[3],[1,2]} QL2看起来

Ambiguous assignment in erlang using date & time

I'm following Programming in Erlang, Software for a concurrent world written by Joe Armstrong and I am trying to figure out what is asking me solve as an assignment at the end of the sequential chapter. Here is the assignment: Look up the definitions of erlang:now/0 erlang:date/0 and erlang:time/0 . Write a function called `my_time_func(F), which evaluates the fun F and times how long it

使用日期和时间在erlang中进行模糊赋值

我正在使用Erlang编程,一个由Joe Armstrong编写的并发世界的软件,我试图找出在顺序章节末尾要求我解决什么问题。 这是作业: 查找erlang:now/0的定义erlang:now/0 erlang:date/0和erlang:time/0 。 编写一个名为`my_time_func(F)的函数,它可以评估有趣的F和时间,它需要多长时间。 我不明白这项任务要求我做什么。 你可以给我举例说明不同的论点或其他解释吗? 它希望你编写一个函数来计算运行另一个函数需要多长时

Difference ok and end [Erlang]

What is the difference in ending a function with end and ok in Erlang? I've been trying to grasp the meaning in the following code: -module(esOne). -export([start/1, func/1]). start(Par) -> io:format("Client: I am ~p, spawned by the server: ~p~n",[self(),Par]), spawn(esOne, func, [self()]), Par ! {onPid, self()}, serverEsOne ! {onName, self()}, receiveMessage(),

差异确定并结束[Erlang]

在Erlang结束一个函数结束和确定的区别是什么? 我一直在努力去掌握以下代码中的含义: -module(esOne). -export([start/1, func/1]). start(Par) -> io:format("Client: I am ~p, spawned by the server: ~p~n",[self(),Par]), spawn(esOne, func, [self()]), Par ! {onPid, self()}, serverEsOne ! {onName, self()}, receiveMessage(), ok. receiveMessage() -> receive {reply

Which Erlang implementation of OpenId should I use, if any?

I'd need an Erlang implementation of the OpenId protocol. I found the following, but it seems to be a project on its early stage. http://code.google.com/p/erlopenid/ Any hint or suggestion on what should I use? I finally found all the existing Erlang implementations for OpenID thanks to the following search engine for Erlang projects: http://projects.trapexit.org/web/ Here are the

我应该使用哪种OpenId的Erlang实现?

我需要一个OpenId协议的Erlang实现。 我发现了以下内容,但它似乎是一个早期阶段的项目。 http://code.google.com/p/erlopenid/ 任何暗示或建议我应该使用什么? 我终于找到了所有现有的用于OpenID的Erlang实现,这要感谢Erlang项目的以下搜索引擎: http://projects.trapexit.org/web/ 结果如下: http://github.com/etnt/eopenid http://github.com/brendonh/erl_openid http://github.com/pib/erlangopenid

How to send multicast messages and reuse a port in Erlang?

I have gotten a good start on my program, my first REAL Erlang program. I have it listening for messages, reading them and parsing them. I also have it sending them. The one little thing that is bothering me is I can't SEND on Port 5353, I have tried everything. All the other applications on my machine can listen AND send on port 5353, SubEthaEdit, iTunes, iChat. The solution MUST broad

如何发送多播消息并重用Erlang中的端口?

我的程序,我的第一个真正的Erlang程序已经获得了良好的开端。 我让它听取消息,阅读并解析它们。 我也有它发送。 困扰我的一件小事是我无法在端口5353上发送,我尝试了一切。 我的机器上的所有其他应用程序都可以侦听并发送端口5353,SubEthaEdit,iTunes,iChat。 该解决方案必须在端口5353上广播发送,这是原因。 “如果收到的组播DNS查询中的源UDP端口不是端口5353,则表示发起查询的客户端是一个简单的客户端,并未

how to suppress "PROGRESS REPORT" from Erlang interactive shell

I'm using Erlang/OTP 20 on macOS. Eshell prints multiple lines with heading "PROGRESS REPORT", I want it to not print that. Inverse grep ing and similar work around are not desirable. Here's a sample of statements getting printed: =PROGRESS REPORT==== 28-Aug-2017::22:39:40 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.59.0>}, {id,alarm_handler}, {mfargs,{a

如何从Erlang交互式shell中压缩“PROGRESS REPORT”

我在macOS上使用Erlang / OTP 20。 Eshell用标题“PROGRESS REPORT”打印多行,我希望它不打印。 反向grep ing和类似的工作是不可取的。 以下是获取打印的语句示例: =进度报告==== 2017年8月28日:: 22:39:40 ===主管:{本地,sasl_safe_sup}开始:[{pid,<0.59.0>},{id,alarm_handler},{mfargs ,{alarm_handler,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}] =进度