我有一个代码:
main = interact $ show . maxsubseq . map read . words
maxsubseq :: (Ord a,Num a) => [a] -> (a,[a])
maxsubseq = snd . foldl f ((0,[]),(0,[])) where
f ((h1,h2),sofar) x = (a,b) where
a = max (0,[]) (h1 + x ,h2 ++ [x])
b = max sofar a
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
maxSub.hs:6:17: error: Variable not in scope: h1
maxSub.hs:6:22: error: Variable not in scope: x
maxSub.hs:6:25: error: Variable not in scope: h2 :: [t1]
maxSub.hs:6:32: error: Variable not in …Run Code Online (Sandbox Code Playgroud) 我有一个带有文件输入字段的表单:
profile.blade.php
<form id="profile-form" name="profile-form" class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="{{url('user/profileAction')}}">
{{csrf_field()}}
<div class="form-group">
<div class="col-xs-12">
<label class="col-sm-3 control-label no-padding-right" for="avatar"> Avatar </label>
<div class="col-xs-12 col-sm-5">
<input type="file" id="avatar" name="avatar" value="{{$user->avatar}}">
</div>
</div>
</div>
<div class="clearfix form-actions">
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-success btn-submit" type="submit">
<i class="ace-icon fa fa-save fa-fw bigger-110"></i> Save changes</button>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
web.php
Route::post('user/profileAction', 'UserController@profileAction');
Run Code Online (Sandbox Code Playgroud)
UserController.php
class UserController extends Controller
{
public function profileAction(Request $request)
{
dd($request->all());
}
}
Run Code Online (Sandbox Code Playgroud)
脚本
<script type="text/javascript">
jQuery(function ($) {
function show() …Run Code Online (Sandbox Code Playgroud) 我有一个代码,用于计算Motzkin数字:
module Main where
-- Program execution begins here
main :: IO ()
main = interact (unlines . (map show) . map wave . (map read) . words)
-- Compute Motzkin number
wave :: Integer -> Integer
wave 0 = 1
wave 1 = 1
wave n = ((3 * n - 3) * wave (n - 2) + (2 * n + 1) * wave (n - 1)) `div` (n + 2)
Run Code Online (Sandbox Code Playgroud)
但即使是简单数字的输出也30需要一段时间才能返回.
任何优化的想法?
我正在尝试使用Segment Tree 来解决频繁的值
这篇博客文章使用了类似的方法
我想将列表分成以下间隔:
-1 -1 1 1 1 1 3 10 10 10 变 (0, 2) (2, 6) (6, 7), (7, 10)
我有一个代码:
g s = map (\x->(head x, length x)) . group . sort $ s
Run Code Online (Sandbox Code Playgroud)
但它没有给出正确的输出.
是否可以使用频繁的值?
我有一份清单
let a = [1,2,3,4]
我想一次提取2个元素来执行计算.谁能告诉我这是如何实现的?我是Haskell的新手.
我知道take 2 a.但是我如何将它放在一个循环中,以便一次提取2个元素.我很迷惑.