--- layout: default title: "Tuples" parent: Composite ancestor: Funcons-beta --- [Funcons-beta] : [Tuples.cbs] ----------------------------- ### Tuples
[
  Datatype tuples
  Funcon   tuple-elements
  Funcon   tuple-zip
]
Meta-variables
  T1, T2 <: values
  T1+, T2+ <: values+
  T*, T1*, T2* <: values*
Datatype 
  tuples(T*) ::= tuple(_:T*)
T* can be any sequence of types, including ( ) and values*. The values of type tuples(T1, ..., Tn) are of the form tuple(V1, ..., Vn) with V1:T1, ..., Vn:Tn.
Funcon
  tuple-elements(_:tuples(T*)) : =>(T*)
Rule
  tuple-elements(tuple(V*:T*)) ~> V*
Funcon
  tuple-zip(_:tuples(values*), _:tuples(values*)) : =>(tuples(values,values))*
tuple-zip(TV1, TV2) takes two tuples, and returns the sequence of pairs of their elements, provided that they have the same length. If they have different lengths, the last elements of the longer sequence are ignored.
Rule
  tuple-zip(tuple(V1:T1, V1*:T1*), tuple(V2:T2, V2*:T2*))
   ~> (tuple(V1, V2), tuple-zip(tuple(V1*), tuple(V2*)))
Rule
  tuple-zip(tuple( ), tuple( )) ~> ( )
Rule
  tuple-zip(tuple(V1+:T1+), tuple( )) ~> ( )
Rule
  tuple-zip(tuple( ), tuple(V2+:T2+)) ~> ( )
____ From the [PLanCompS Project] | [CBS-beta issues...] | [Suggest an improvement...] [Tuples.cbs]: Tuples.cbs "CBS SOURCE FILE" [Funcons-beta]: /CBS-beta/docs/Funcons-beta "FUNCONS-BETA" [Unstable-Funcons-beta]: /CBS-beta/docs/Unstable-Funcons-beta "UNSTABLE-FUNCONS-BETA" [Languages-beta]: /CBS-beta/docs/Languages-beta "LANGUAGES-BETA" [Unstable-Languages-beta]: /CBS-beta/docs/Unstable-Languages-beta "UNSTABLE-LANGUAGES-BETA" [CBS-beta]: /CBS-beta "CBS-BETA" [PLanCompS Project]: https://plancomps.github.io "PROGRAMMING LANGUAGE COMPONENTS AND SPECIFICATIONS PROJECT HOME PAGE" [CBS-beta issues...]: https://github.com/plancomps/CBS-beta/issues "CBS-BETA ISSUE REPORTS ON GITHUB" [Suggest an improvement...]: mailto:plancomps@gmail.com?Subject=CBS-beta%20-%20comment&Body=Re%3A%20CBS-beta%20specification%20at%20Values/Composite/Tuples/Tuples.cbs%0A%0AComment/Query/Issue/Suggestion%3A%0A%0A%0ASignature%3A%0A "GENERATE AN EMAIL TEMPLATE"