首页 \ 问答 \ 用sencha touch 2做一个不错的路由器(Make a nice router with sencha touch 2)

用sencha touch 2做一个不错的路由器(Make a nice router with sencha touch 2)

我正在使用sencha touch 2应用程序,我想制作一个包含许多控制器的优秀路由器,就像在常规Web应用程序中一样。

我怎样才能做到这一点? 例如,我想将特定控制器/操作上的每个URL重定向为:

/:controller/:action

我怎样才能做到这一点?


I am working with a sencha touch 2 application and i want to make a great router with many controllers, as in a regular web application.

How can i do that? For exemple, i want to redirect each url on the specific controller/action as :

/:controller/:action

How can i do that?


原文:https://stackoverflow.com/questions/10615947
更新时间:2023-09-09 21:09

最满意答案

通常, 折叠是在称为monoid [wiki]的代数结构上完成的。

幺半群是代数结构。 它在具有关联函数f的集合S上定义(模数不是关联函数)。 此外,应该有一个元素e∈S ,称为“* identity”元素。 f(e,x)= xf(x,e)= x的元素。

人们可以证明,对于一个幺半群总是有一个单位元素(所以不可能构造一个幺半群,其中两个元素是单位元素。证明如下:说有两个元素ab是中性元素,有一个≠b ,然后f(a,b)= a (上面的定义),但f(a,b)= b也成立,因为函数只能返回一个元素,而a≠b ,我们已经达成了矛盾。因此可以得出结论: a = b

我们不能为模运算(以及自然,整数,...)数定义一个monoid,因为运算符应该是关联的 ,对于这些集,它不能保持: (a%b)%c = a% (b%c)

回答你的问题(一般来说):

模数运算符的标识元素是什么? %(身份,a)= a

如果我们采用自然的,积分的,理性的,真实的等数字,那么模数就没有一个恒等元素。

是否有任何特定属性,运营商必须遵循这些属性才能拥有身份?

简单地说,存在元素e∈S ,使得f(x,e)= x 。 我们可以从每个函数“构造”这样的函数,只需选择一个元素e∈S ,然后将其定义为: f'(x,y)= x如果y = ef'(x,y)= f( x,y)否则。

如果运算符具有标识,是否有通用的方法来查找运算符的标识。

由于上面的内容表明我们可以为每个函数构造这样的函数,因此据我所知,没有一般方法可以为运算符的标识元素提供资金。


Typically a fold is done over an algebraic structure called a monoid [wiki].

A monoid is an algebraic structure. It is defined over a set S with an associative function f (modulo is not an associative function). Furthermore there should be an element e ∈ S that is called the "*identity" element. An element such that f(e,x) = x and f(x,e) = x.

One can proof that for a monoid there is always one identity element (so it is impossible to construct a monoid where two elements are identity elements. The proof is a follows: say there are two elements a and b that are neutral elements, with a ≠ b, then f(a,b) = a (definition above), but f(a,b)=b also holds, since a function can only return one element, and a≠ b, we have reached a contradiction. We can furthermore thus conclude that a = b.

We can not define a monoid for the modulo operation (and natural, integral, ...) numbers, since the operator should be associative, and for these sets, it does not hold that: (a % b) % c = a % (b % c).

To answer your questions (in general):

What is identity element for modulus operator if it exists? %(identity, a) = a

If we take natural, integral, rational, real, etc. numbers, then modulo does not have an identity element.

Are there any specific properties that the operator must follow to have an identity?

Simply that there is an element e ∈ S such that f(x, e) = x. We can "construct" such function from every function, by simply picking an element e ∈ S, and then define it as: f'(x,y) = x if y = e and f'(x,y) = f(x,y) otherwise.

Is there a general way to find the identity of an operator if it has an identity.

Since the above shows that we can construct such function for every function, there are no general methods as far as I know to fund the identity element of an operator.

相关问答

更多
  • 你需要divisibleby ,一个内置的django过滤器。 {% for p in posts %}
  • 您可以as使用自己的tail as zip序列: for ((prev, curr) <- as zip as.tail) { // do something with `prev` and `curr` } 或者你可以使用sliding : for (window <- as.sliding(2)) { val prev = window(0) val curr = window(1) // do something with `prev` and `curr` } You could ...
  • 在x86架构上,DIV指令返回AX中的商和DX中的余数。 The DIV instruction returns the quotient in AX and the remainder in DX, on the x86 architecture.
  • fold-left fold-right使用从第一个元素到最后一个元素的缩小过程减少一个或多个列表,但是它应用的顺序保持在fold-right而在fold-left 。 如果您执行以下操作,则很容易显示: #!r6rs (import (rnrs)) ;; helper for R6RS fold-left since argument order is swapped (define (xcons d a) (cons a d)) (fold-left xcons '() '(1 2 3 4)) ...
  • 向零截断意味着通过选择下一个最接近零的整数将实数转换为整数。 等价地,您将数字写下来,并忽略小数点后的所有内容,无论数字是正数还是负数。 考虑11/4 = 2.75 - 如果你将它截断为零,你会得到2。 考虑-11/4或11 / -4 = -2.75 - 如果你将此截断为零,则得-2。 (a / b)* b + a%b == a的一些数学运算很重要。 如果我们必须保持这个等式,并且我们也接受整数除法截断为零,那么我们可以推导出%运算符的操作如下: a == 11, b == 4: a/b == 2, 2*4 ...
  • 要扩展其他答案,如果你取正数的模数和2的正幂(即a % b ,其中b是2的幂, a和b是正数),你可以有效地替换%运算符&运算符(并从b中减去1,因此它变为a & (b - 1) )。 这是因为&运算符执行了一个按位掩码,并且一个数量为2的幂的结果恰好是该数字的低位。 这只适用于右手参数是2的幂并且两个数都是正数的情况。 否则,请使用%运算符。 To expand on the other answers, if you take the modulus of a positive number and a ...
  • 结果完全正确。 模块化算术定义以下(我将使用“congruent”,因为我不能用三行键入等号) 一致的b mod c iff ab是c的倍数,即对于某个整数x,x * c =(ab)。 例如 0 congruent 0 mod 5 (0 * 5 = 0-0) 1 congruent 1 mod 5 (0 * 5 = 1-1) 2 congruent 2 mod 5 (0 * 5 = 2-2) 3 congruent 3 mod 5 (0 * 5 = 3-3) 4 congruent 4 mod 5 (0 * ...
  • 你很亲密 唯一的问题是你传递给fold的函数中的if / else情况。 请记住,在你的fn (x,y) , x是你正在考虑的列表元素, y是折叠列表其余部分的结果。 如果f(x)失败,那么你想从结果中排除x ,所以你只需要传递y 。 如果f(x)成功,则希望在结果中包含x ,因此返回y@[x] 。 注意,最好避免使用append运算符( y@[x] ),因为它是线性时间运算,而prepending( x::y )是常量。 当然,在这种情况下用一个代替另一个将向后构建你的列表。 你可以通过向后折叠来解决这个 ...
  • 通常, 折叠是在称为monoid [wiki]的代数结构上完成的。 幺半群是代数结构。 它在具有关联函数f的集合S上定义(模数不是关联函数)。 此外,应该有一个元素e∈S ,称为“* identity”元素。 f(e,x)= x和f(x,e)= x的元素。 人们可以证明,对于一个幺半群总是有一个单位元素(所以不可能构造一个幺半群,其中两个元素是单位元素。证明如下:说有两个元素a和b是中性元素,有一个≠b ,然后f(a,b)= a (上面的定义),但f(a,b)= b也成立,因为函数只能返回一个元素,而a≠b ...
  • expr是一个命令,不是csh的一部分。 您必须转义*以防止csh尝试扩展它,如 set aVAr =`expr $number \* 2 % $frequency` expr is a command, not part of csh. You must escape the * to prevent csh from trying to expand it, as in set aVAr =`expr $number \* 2 % $frequency`

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)