给定一个像这样的HTML文件:
<html>
<header ui-view="header"></header>
<div class="main" ui-view></div>
<footer ui-view="footer"></footer>
</html>
Run Code Online (Sandbox Code Playgroud)
如何创建一个布局状态,用标题模板填充"标题",页脚带有页脚模板,然后允许子状态填充空的ui视图?
我想空的ui-view也可以命名为ui-view ="main".
Less允许选择父选择器(http://lesscss.org/features/#parent-selectors-feature)
如何获得直接父选择器,而不是根父选择器?
我用的时候>> nonexistent/file.log.Bash给了我"没有这样的文件或目录".
如何将STDOUT/STDERR重定向到日志文件,即使它不存在?如果它不存在,则必须创建必要的文件夹和文件.
我希望能够用模板替换原始元素标记.当使用"replace = true"属性时,这应基本上与transclusion相同.
根据这个答案:https://stackoverflow.com/a/1952480/582917
我可以读入并因此分配多个变量.
但是我希望这些变量是bash函数的本地变量,因此它不会污染全局范围.
有没有办法做这样的事情:
func () {
local read a b <<< $(echo 123 435)
echo $a
}
func
echo $a
Run Code Online (Sandbox Code Playgroud)
以上不起作用.阅读局部变量的好方法是什么?
编写bash脚本时.有时你正在运行一个命令,打开另一个程序,如npm,composer等.但同时你需要使用read以提示用户.
你不可避免地遇到这种错误:
read: read error: 0: Resource temporarily unavailable
Run Code Online (Sandbox Code Playgroud)
在做了一些研究后,似乎有一个解决方案,通过管道那些操作bash脚本的STDIN的程序的STDIN到/ dev/null.
就像是:
npm install </dev/null
Run Code Online (Sandbox Code Playgroud)
其他研究表明它与STDIN被设置为某种阻塞/阻塞状态这一事实有关,并且在程序完成后它没有被重置.
问题是有某种傻瓜证明,优雅的方式读取用户提示输入而不受那些操纵STDIN的程序的影响,而不必寻找哪些程序需要将其STDIN重定向到/ dev/null.您甚至可能需要使用这些程序的STDIN!
Numpy在其阵列访问运算符中具有复杂的索引/切片/步进功能.请参阅:http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
在尝试使用Haskell时,我认为尝试复制此索引功能的子集会很有教育意义.具体来说,它是"元组选择对象"或n维投影"(https://en.wikipedia.org/wiki/Projection_%28relational_algebra%29).
基本上你可以这样做:
two_d_array[0:1:1, 0:4:2]
Run Code Online (Sandbox Code Playgroud)
这将为您提供第一行,步长为1,包含前两列2(跳过1列).
换句话说,它可以将原始的二维数组投影到一个较小的二维数组中.结果仍然是二维数组.
所以这就是我在Haskell中尝试过的.
这样的函数的类型应该是这样的:
(!!!) :: (Functor f) => f a -> [(Int, Int, Int)] -> f a
Run Code Online (Sandbox Code Playgroud)
所以你可以看到类似的东西:
three_d_tensor !!! [(s1,e1,st1), (s2,e2,st2), (s3,e3,st3)]
Run Code Online (Sandbox Code Playgroud)
其中sx,ex,stx分别为start,end,step.
该示例应将原始张量投影为较小的张量,第一维受限制s1 to e1, stepping by st1,第二维受s2 to e2, stepping by st2......等限制.
所以这就是我得到的:
slicing from to xs = take (to - from + 1) (drop from xs)
stepping n = map head . takeWhile (not . null) . iterate (drop n)
(!!!) …Run Code Online (Sandbox Code Playgroud) 在之前的问题SystemT编译器和处理Haskell中的无限类型时,我询问了如何将SystemT Lambda微积分解析为SystemT组合器.我决定使用普通代数数据类型来编码SystemT Lambda演算和SystemT Combinator演算(基于注释:SystemT编译器和处理Haskell中的无限类型).
SystemTCombinator.hs:
module SystemTCombinator where
data THom = Id
| Unit
| Zero
| Succ
| Compose THom THom
| Pair THom THom
| Fst
| Snd
| Curry THom
| Eval
| Iter THom THom
deriving (Show)
Run Code Online (Sandbox Code Playgroud)
SystemTLambda.hs:
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TypeSynonymInstances #-}
module SystemTLambda where
import Control.Monad.Catch
import Data.Either (fromRight)
import qualified SystemTCombinator as SystemTC
type …Run Code Online (Sandbox Code Playgroud) 我正在研究Haskell的类型族特征,以及类型级计算.看起来很容易使用以下方法获得类型级别的参数多态性PolyKinds:
{-# LANGUAGE DataKinds, TypeFamilies, KindSignatures, GADTs, TypeOperators, UndecidableInstances, PolyKinds, MultiParamTypeClasses, FlexibleInstances #-}
data NatK = Z | S NatK
data IntK = I NatK NatK
infix 6 +
type family (x :: NatK) + (y :: NatK) :: NatK where
Z + y = y
(S x) + y = S (x + y)
-- here's a parametrically polymorphic (==) at the type-level
-- it also deals specifically with the I type of kind IntK
infix 4 …Run Code Online (Sandbox Code Playgroud) 这个问题包括将玫瑰树折叠成路径的代码折叠玫瑰树路径.我正在尝试无限的玫瑰树,我发现所提供的解决方案并不足以在宽度和宽度上无限的玫瑰树上工作.
考虑像玫瑰树一样:
data Rose a = Rose a [Rose a] deriving (Show, Functor)
Run Code Online (Sandbox Code Playgroud)
这是一棵有限的玫瑰树:
finiteTree = Rose "root" [
Rose "a" [
Rose "d" [],
Rose "e" []
],
Rose "b" [
Rose "f" []
],
Rose "c" []
]
Run Code Online (Sandbox Code Playgroud)
边路径列表的输出应为:
[["root","a","d"],["root","a","e"],["root","b","f"],["root","c"]]
Run Code Online (Sandbox Code Playgroud)
这是两个维度中的无限玫瑰树:
infiniteRoseTree :: [[a]] -> Rose a
infiniteRoseTree ((root:_):breadthGens) = Rose root (infiniteRoseForest breadthGens)
infiniteRoseForest :: [[a]] -> [Rose a]
infiniteRoseForest (breadthGen:breadthGens) = [ Rose x (infiniteRoseForest breadthGens) | x <- breadthGen ]
infiniteTree = infiniteRoseTree …Run Code Online (Sandbox Code Playgroud) haskell ×4
bash ×3
angularjs ×2
algorithm ×1
composition ×1
css ×1
data-kinds ×1
fold ×1
interpreter ×1
less ×1
numpy ×1
ocaml ×1
polymorphism ×1
recursion ×1
redirect ×1
shell ×1
tree ×1
typeclass ×1
types ×1