记下今天mathematica中用的两个新函数

第一个  Flatten

用法:这个是help brows上的   

Flatten[list]
flattens out nested lists.
Flatten[list,n]
flattens to level n.
Flatten[list,n,h]
flattens subexpressions with head h.
Flatten[list,{{Subscript[s, 11],Subscript[s, 12],[Ellipsis]},{Subscript[s, 21],Subscript[s, 22],[Ellipsis]},[Ellipsis]}]
flattens list by combining all levels Subscript[s, ij] to make each level i in the result.

这个理解有点难度呵呵,其实也就是那个意思嘎嘎

看下里面的 Basic examples

一,Flatten out lists at all levels:

      In[1]:=Flatten[{{a, b}, {c, {d}, e}, {f, {g, h}}}]

      Out[1]:= {a, b, c, d, e, f, g, h}

二,Flatten only at level 1:

       In[1]:= Flatten[{{a, b}, {c, {d}, e}, {f, {g, h}}}, 1]

      Out[1]:={a, b, c, {d}, e, f, {g, h}}

好了例子就是这个了,不过注意是basic呵呵

第二个  Intersection

Intersection[Subscript[list, 1],Subscript[list, 2],[Ellipsis]]
gives a sorted list of the elements common to all the Subscript[list, i].

Basic examples

Find elements common to all the lists given:

In[1]:=Intersection[{1, 1, 2, 3}, {3, 1, 4}, {4, 1, 3, 3}]

Out[1]:={1, 3}

好了用法就是这样的~

主要是解决公交换乘问题换乘一次的方案实施~

好吧,洗洗睡了,上次的lingo分析还没彻底搞好,真是悲了个剧,算了睡觉,我还想再活五百年~

发表评论

电子邮件地址不会被公开。 必填项已用*标注