bootstrap网格 - 3列和2行分成2列和3行(bootstrap grid - 3 columns and 2 rows into 2 columns and 3 rows)
嗨,我有典型的引导网格
<div class="row"> <div class="col-sm-4" align="center" style="font-size:150px">A</div> <div class="col-sm-4" align="center" style="font-size:150px">B</div> <div class="col-sm-4" align="center" style="font-size:150px">C</div> </div> <div class="row"> <div class="col-sm-4" align="center" style="font-size:150px">D</div> <div class="col-sm-4" align="center" style="font-size:150px">E</div> <div class="col-sm-4" align="center" style="font-size:150px">F</div> </div>
在更大或中等的屏幕上显示
A B C D E F
在一个非常小的屏幕上显示
A B C D E F
好了,现在我的问题。 这是否可以在非常小的屏幕上显示最后一列作为最后一列
A B D E C F
比你的帮助。
Hi I have typical bootstrap grid
<div class="row"> <div class="col-sm-4" align="center" style="font-size:150px">A</div> <div class="col-sm-4" align="center" style="font-size:150px">B</div> <div class="col-sm-4" align="center" style="font-size:150px">C</div> </div> <div class="row"> <div class="col-sm-4" align="center" style="font-size:150px">D</div> <div class="col-sm-4" align="center" style="font-size:150px">E</div> <div class="col-sm-4" align="center" style="font-size:150px">F</div> </div>
On a larger or medium screen it shows
A B C D E F
On a very small screen it shows
A B C D E F
Ok now my question. Is this possible to make on very small screen to show last colum as last row
A B D E C F
Than you for help.
原文:https://stackoverflow.com/questions/48012731
最满意答案
我可以想出两种避免警告的方法。 第一种也是最简单的方法是为
toResult
添加另一个方程式,它捕获所有其他大小的列表并提供信息性错误:toResult :: [SqlValue] -> IO Course toResult [ ... ] = do ... --Your existing code goes here toResult xs = error $ "toResult: List must contain exactly six values (recieved " ++ length xs ++ ")."
但是如果你的函数只设计为长度为6的列表,我怀疑列表是否真的是这里使用的最佳数据结构。
理想情况下,您的函数类型签名应该让读者很清楚地知道如何使用该函数。 如果您的函数只能接受长度为6的列表,那么它的类型签名将无法与之通信。 我建议选择不具有可变长度的不同数据结构,例如6元组(可能与
type
或newtype
结合使用)或自定义data
类型。 这完全消除了基于长度的模式匹配问题,并使您的功能更容易从“外部世界”中理解。在不了解更多上下文的情况下,我无法确切地知道在您的情况下哪种常量大小的数据结构最合适,但这里有一个简单的示例,希望能够说明我所描述的方法的好处:
--Explicitly hexadic type signature (might benefit from some aliasing) toResult :: (SQLValue, SQLValue, SQLValue, SQLValue, SQLValue, SQLValue) -> IO Course toResult ( fromSql -> courseid, fromSql -> title, fromSql -> name, fromSql -> version, fromSql -> cdate, fromSql -> fid ) = do ... --No need for separate equations due to constant-size container
不幸的是,如果你无法从这种情况中完全删除
List
类型,那么所有这一切都会将问题转移到其他地方,因为你最终需要第二个函数来从List转换为元组。 这些类型的功能总是难看并且难以使用。在编译时,GHC无法保证满足要求(即,正好传递六个值)这一事实是不可能的。 即使你100%表示
quickQuery
会返回一个包含六个元素的列表(你真的,完全地,在数学上确定这一点吗?),你仍然必须考虑到这种情况的逻辑可能性。 这意味着您必须在运行时提供一种处理此案例的方法。那么,当传递多于或少于六个值时,您想要做什么? 如何在您的程序中实现错误处理? 这是一个使用
error
的潜在天真的例子:sixValues :: [SQLValue] -> (SQLValue, SQLValue, SQLValue, SQLValue, SQLValue, SQLValue) sixValues [a,b,c,d,e,f] = (a,b,c,d,e,f) sixValues xs = error "Wrong number of values"
虽然没有比我的第一个建议好多少,但这至少具有将长度处理逻辑与结果生成逻辑分开的优点。
I appreciate the input and learning that I have received from this experience. However, I have progressed from a working function that issued a compile-time warning that I was comfortable ignoring to a compile error that prevents building the output executable.
I have incorporated a couple of the suggestions from this thread, but have basically gone back to my original warning about a non-exhaustive pattern match. It seems, in the end, that there is an irreconcilable incongruity between executing a database query that always returns a list of the same number of elements and then using that list as, or converting that list to, a fixed-size collection.
Every language has its quirks. Maybe this is one for Haskell.
Thanks for all the input and guidance.
Dave Smith
相关问答
更多-
你的第二行有lastButone ,但你的意思是lastButOne 。 哎呦! :) You have lastButone on your second line but you mean lastButOne. Whoops! :)
-
我可以想出两种避免警告的方法。 第一种也是最简单的方法是为toResult添加另一个方程式,它捕获所有其他大小的列表并提供信息性错误: toResult :: [SqlValue] -> IO Course toResult [ ... ] = do ... --Your existing code goes here toResult xs = error $ "toResult: List must contain exactly six values (recieved " ++ lengt ...
-
问题是你定义了两个子句: 一个空列表 cwords "" = 0 还有一个列表至少包含两个元素: cwords (a:b:c) = ... 所以Haskell说,如果字符串只包含一个字符,它就不知道该做什么,因为没有子句指定在这种情况下要做什么。 既然你数了单词,如果我们获得最后一个字符,我们应该把它算作一个单词(因为它是一个字母字符)。 所以代码应该是这样的: cwords :: String -> Int cwords "" = 0 cwords (a:b:c) |isAlpha a && ...
-
问题正是因为type Nodo = String的定义。 由于String本身是Char的列表,这意味着当你拥有模式时 buscaNodo _ [] = False 这相当于 buscaNodo _ "" = False 你实际上匹配空字符串。 您可能想要的是切换这些参数: buscaNodo [] _ = False 查找空列表中的任何元素( _ )将始终返回False 。 您还可以使用Haskell附带的内置函数大大简化此定义: buscaNodo :: [(Nodo, Peso)] -> Nod ...
-
模式匹配失败例外是PatternMatchFail类型。 基本异常都在Control.Exception中定义。 下面是使用Control.Exception.catch来捕捉你所谈论的类型的模式匹配失败。 在这里,我的操作和处理函数都是IO ()类型,但是你可以做任何你想要的 - 如果操作是IO Int那么异常处理程序可以返回一个默认的IO Int 。 {-# LANGUAGE ScopedTypeVariables #-} import Control.Exception as X func = X. ...
-
非穷举模式匹配只是因为我遗漏了`否则=`?(Non-exhaustive pattern matches only because I left off `otherwise =`? [duplicate])[2021-09-28]
GHC根本不知道a > b , a < b或a == b必须评估为True 。 (事实上,编写一个违反这个假设的Ord实例是可能的 - 尽管大多数程序员不会考虑这样做,当然Int实例在这方面会表现得很好。) 你可以很明显地看到,GHC已经通过使用完整的模式匹配来覆盖所有的情况,例如 respond correct guess = case compare guess correct of GT -> ... LT -> ... EQ -> ... GHC在其严格性检查器中也有特殊情 ... -
你的第二个let定义一个新的double 。 您可以像这样在GHCi中定义多行功能。 λ :{ | let | double :: Num a => [a] -> [a] | double [] = [] | double (x:xs) = 2 * x : double xs | :} λ double [1,2,3] [2,4,6] 请注意,这相当于map (2*) 。 Your second let is defining a new double. You can define multi-line ...
-
正如人们在评论中指出的那样,GHCi 8的单行定义取代了之前的定义。 如果您想输入多模式定义,则需要使用特殊的:{和:}代码来启动和结束多行命令。 所以,以下工作正常: Prelude> :{ Prelude| fact 0 = 1 Prelude| fact n = n * fact (n-1) Prelude| :} Prelude> fact 10 3628800 Prelude> (请注意,这仅适用于GHCi 8,不适用于7.) 另外,请介意您的定义中的顺序。 在Haskell中,模式的顺序很重 ...
-
Haskell初学者,递归函数,列表,错误:非详尽模式(Haskell Beginner, recursive function, list, Error: Non-exhaustive patterns)[2021-11-11]
问题是您的模式只匹配一个元素的列表。 例如,如果您尝试在ghci定义函数: a [x] = x 然后尝试使用具有不同数量元素的列表来调用它: a [1]结果为1 a []结果为Exception::5:1-13: Non-exhaustive patterns in function a a [1,2]结果为Exception: :1:1-9: Non-exhaustive patterns in function a 以下修改使您的功能工作: sum ... -
你没有包含一个定义,当你插入的树是Nil时会发生什么,大概看起来像 genTree x Nil = singleton x 你试图用这条线做到这一点 genTree x (Node e l r) = if (Node e l r == Nil) then singleton x else ... 但如果你考虑一下,你会发现它无法奏效。 模式匹配确保您正在查看的树的形式为Node _ _ _ ,因此它永远不会为Nil 。 也就是说, if表达式中的测试总是计算为False 。 You ha ...