
我得到这个试图上呈现three.js所立方体,使用THREE.MeshBasicMaterial()和加载质感.
这是正常的吗?我该如何解决?
BLC如何编码括号?例如,这将是怎样的:
?a.?b.?c.(a ((b c) d))
Run Code Online (Sandbox Code Playgroud)
用BLC编码?
注意:维基百科的文章不是很有用,因为它使用了一个不熟悉的符号,只提供了一个不涉及括号的简单示例,以及一个很难分析的非常复杂的示例.该论文在这方面是相似的.
通过无边折叠,我的意思是关联运算符的假设原始折叠操作,不保证任何排序.也就是说,(fold + 0 [a b c d])可能是(+ (+ a b) (+ c d))或(+ (+ (+ a b) c) d).
鉴于这个操作是可融合的,高度可兼容的和通用的,我已经考虑将它与我的非递归极简主义语言一起包含在内map并concat作为唯一的列表原语.我已经设法用它来实现大多数列表功能,但不是双面折叠foldl/ foldr自己.可能吗?
haskell functional-programming mapreduce lambda-calculus racket
我已将 Haskell 应用程序移植到 CUDA 以加速它。现在,我有一个.cu文件想要从 Haskell 作为 API 调用。我已经通过遵循教程轻松地管理了 FFI C 文件,但我不确定这如何应用于 CUDA/nvcc。如何通过 FFI 访问 CUDA 源文件中定义的符号?
为了完成,这就是我尝试将其视为.cu普通.c文件的内容:
vh:CUDA apple1$ nvcc hello.cu -c -o hello.o
vh:CUDA apple1$ ghc test.hs -o test hello.o
Linking test ...
Undefined symbols for architecture x86_64:
"___cudaRegisterFatBinary", referenced from:
__sti____cudaRegisterAll_40_tmpxft_00002168_00000000_7_hello_cpp1_ii_f33df8d2() in hello.o
"___cudaRegisterFunction", referenced from:
__nv_cudaEntityRegisterCallback(void**) in hello.o
"___cudaUnregisterFatBinary", referenced from:
__cudaUnregisterBinaryUtil() in hello.o
"_cudaConfigureCall", referenced from:
render(Renderer_*) in hello.o
"_cudaFree", referenced from:
renderer_free(Renderer_*) in hello.o
"_cudaLaunch", referenced from:
cudaError …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个带有API的纯功能数据结构,例如:
insert :: Vector n Int -> Struct n -> Struct n
remove :: Vector n Int -> Struct n -> Struct n
nearest :: Vector n Int -> Struct n -> Vector n Int
Run Code Online (Sandbox Code Playgroud)
或者其中的一些变体,提供对n维空间中的最近元素的快速插入,移除和查询.那个数据结构是什么?
我想加快以下功能:
{-# LANGUAGE BangPatterns #-}
import Data.Word
import Data.Bits
import Data.List (foldl1')
import System.Random
import qualified Data.List as L
data Tree a = AB (Tree a) (Tree a) | A (Tree a) | B (Tree a) | C !a
deriving Show
merge :: Tree a -> Tree a -> Tree a
merge (C x) _ = C x
merge _ (C y) = C y
merge (A ta) (A tb) = A (merge ta tb)
merge (A ta) (B tb) …Run Code Online (Sandbox Code Playgroud) 文章更简单,更容易!声称即使没有"Pi"存在也可以对依赖类型系统进行编码 - 也就是说,你可以重复使用"Lam"构造函数.但是,如果在某些情况下对"Pi"和"Lam"的处理方式不同,那又怎么可能呢?
此外,可以删除"明星"吗?我认为你可以用"λx.x"(id)替换它的所有出现.
给定一个整数n,我如何构建包含所有长度列表的列表,n^2其中包含n每个整数的完全副本x < n?例如,因为n = 2,我们有:
[0,0,1,1], [0,1,0,1], [1,0,0,1], [0,1,1,0], [1,0,1,0], [1,1,0,0]
Run Code Online (Sandbox Code Playgroud)
这可以轻松完成合并permutations和nub:
f :: Int -> [[Int]]
f n = nub . permutations $ concatMap (replicate n) [0..n-1]
Run Code Online (Sandbox Code Playgroud)
但这太低效了.有没有简单的方法来编码高效/直接算法?
依赖类型Lambda编码论文的自我类型(由Peng Fu和Aaron Stump提出)提出了自我类型,据推测,它足以在构造微积分上编码归纳原理和Scott编码数据类型,而不会使系统不一致或引入悖论.
那篇论文的符号太重了,我无法完全理解如何实现它.
究竟什么是Fix和Self的主要区别?或者,换句话说:在什么点上应该限制天真实施的Fix,以便它不会在核心演算上留下任何不一致?
函数式编程语言(如 Haskell)允许用户使用等式表示法来定义函数,其中左侧有多个可以匹配的模式参数,具有任意多个嵌套。例如:
(fun (Ctr A A) (Foo (Tic X)) a b c d e) = a
(fun (Ctr A B) (Foo (Tac Y)) a b c d e) = b
(fun (Ctr B A) (Bar (Tic X)) a b c d e) = c
(fun (Ctr B B) (Bar (Tac Y)) a b c d e) = d
(fun x y a b c d e) = (df x y a b c d e)
Run Code Online (Sandbox Code Playgroud)
不过,假设您想要将该函数编译为不允许嵌套模式匹配的语言。也就是说,您必须将这些子句扁平化为一系列函数,这些函数组合在一起,相当于fun. 例如,在上面的情况下,您可以按如下方式将其展平:
(fun …Run Code Online (Sandbox Code Playgroud)