来自http://www.playframework.org/documentation/2.0/ScalaTodoList
"〜"做了什么以及为什么我在地图之前不需要一个点?
val task = {
get[Long]("id") ~
get[String]("label") map {
case id~label => Task(id, label)
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
在GraalVM架构上实现编程语言的(架构)差异是什么 - 特别是在使用Sulong的Graal,Truffle和LLVM之间?
我计划在GraalVM体系结构上重新实现现有的静态类型编程语言,这样我就可以从Java中使用它而不会有太多麻烦.
目前有三种选择:
我找到了http://support.zeus.com/zws/examples/2005/12/16/hello_world_in_perl_and_c,这两个例子正在运行.
现在我为Ada尝试了这个,我从2天后就无法完成它.
fcgi_stdio.ads
with Interfaces.C;
with Interfaces.C.Strings;
package fcgi_stdio is
function FCGI_Accept return Interfaces.C.int;
pragma Import (C, FCGI_Accept, "FCGI_Accept");
procedure FCGI_printf (str : Interfaces.C.Strings.chars_ptr);
pragma Import (C, FCGI_printf, "FCGI_printf");
end fcgi_stdio;
Run Code Online (Sandbox Code Playgroud)
test.adb
with fcgi_stdio;
with Interfaces.C;
with Interfaces.C.Strings;
procedure Test is
begin
while Integer (fcgi_stdio.FCGI_Accept) >= 0 loop
fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Content-Type: text/plain" & ASCII.LF & ASCII.LF));
fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Hello World from Ada!" & ASCII.LF));
end loop;
end Test;
Run Code Online (Sandbox Code Playgroud)
当我在控制台中运行它时,我收到以下错误:
$ ./test
raised STORAGE_ERROR : stack overflow or erroneous …Run Code Online (Sandbox Code Playgroud) 我想binomial从 Java 调用 Clojure 函数。我遇到的一个问题是它返回不同的数据类型,或者long(例如,n=5,k=3)或BigInt(例如,n=20,k=10)。在Java方面,它应该是一个BigInteger。
至少有两种选择可以克服这个问题,哪一个更好?
longor BigInt)。克洛尤尔
(ns sample.hello
(:import (clojure.lang BigInt)))
(defn binomial
"Calculate the binomial coefficient."
^BigInt [^Integer n ^Integer k]
(let [a (inc n)]
(loop [b 1
c 1]
(if (> b k)
c
(recur (inc b) (* (/ (- a b) b) c))))))
Run Code Online (Sandbox Code Playgroud)
爪哇
public class Hello {
public static final IFn binomial;
static {
Clojure.var("clojure.core", "require").invoke(Clojure.read("sample.hello"));
binomial = Clojure.var("sample.hello", …Run Code Online (Sandbox Code Playgroud) 在下面的例子中,我想知道,为什么line 17不起作用,但是line 18?我可以不System.Address直接转换为Integer(参见line 17)吗?
main.adb
with Ada.Text_IO;
with Ada.Unchecked_Conversion;
with System.Storage_Elements;
procedure Main is
package SSE renames System.Storage_Elements;
type Integer_Access is access Integer;
I1_Access : Integer_Access := new Integer'(42);
I1_Address : System.Address := I1_Access.all'Address;
function Convert1 is new Ada.Unchecked_Conversion (System.Address, Integer);
function Convert2 is new Ada.Unchecked_Conversion (System.Address, Integer_Access);
begin
Ada.Text_IO.Put_Line (SSE.To_Integer (I1_Access'Address)'Img);
Ada.Text_IO.Put_Line (SSE.To_Integer (I1_Access.all'Address)'Img);
Ada.Text_IO.Put_Line (I1_Access.all'Img);
Ada.Text_IO.Put_Line (Convert1 (I1_Address)'Img); -- why does this NOT work?
Ada.Text_IO.Put_Line (Convert2 (I1_Address).all'Img); -- …Run Code Online (Sandbox Code Playgroud) 是否可以从左到右而不是从右到左更改参数调用行为(第25行)?
底部的代码将3 2 1打印到控制台.
with Ada.Containers.Vectors;
with Ada.Text_IO;
procedure Main is
package Vector is new Ada.Containers.Vectors (Positive, Integer);
V : Vector.Vector;
procedure A (X, Y, Z : Integer) is
begin
Ada.Text_IO.Put_Line (X'Img & Y'Img & Z'Img);
end;
function B return Integer is
X : Integer := V.First_Element;
begin
V.Delete_First;
return X;
end;
begin
V.Append (1);
V.Append (2);
V.Append (3);
A (B, B, B);
end Main;
Run Code Online (Sandbox Code Playgroud) 我想写一个"="函数,它可以将A_Access与null对象进行比较.我如何编写"="函数,以便它可以工作?我试试看,见下文.
代码生成一个凸起的CONSTRAINT_ERROR:main.adb:14访问检查失败.
with Ada.Tags;
with Ada.Text_IO;
procedure Main is
type A is tagged
record
a : Integer;
end record;
type A_Access is access all A'Class;
function "=" (Left, Right : A_Access) return Boolean is
use Ada.Tags;
begin
return (Left.all'Tag = Right.all'Tag and then Left.a = Right.a);
end "=";
begin
declare
A_1 : A_Access := new A'(a => 1);
A_2 : A_Access := null;
begin
if A_1 /= A_2 then
Ada.Text_IO.Put_Line (":-)");
end if;
end;
end Main;
Run Code Online (Sandbox Code Playgroud)
我也尝试检查null,但随后,我得到了STORAGE_ERROR:堆栈溢出 …