7 added 19 characters in body edited Oct 19 '13 at 6:00 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now for your second case, you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  OR more elegantly: Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[dateQuantityList[[All,1]], DateListQ] && VectorQ[datePriceList[[All,1]], DateListQ] := ...  Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  OR more elegantly: Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[dateQuantityList[[All,1]], DateListQ] && VectorQ[datePriceList[[All,1]], DateListQ] := ...  Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now for your second case, you can do something like: Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  OR more elegantly: Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[dateQuantityList[[All,1]], DateListQ] && VectorQ[datePriceList[[All,1]], DateListQ] := ...  6 added 234 characters in body edited Oct 19 '13 at 5:53 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  OR more elegantly: Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[dateQuantityList[[All,1]], DateListQ] && VectorQ[datePriceList[[All,1]], DateListQ] := ...  Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  OR more elegantly: Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[dateQuantityList[[All,1]], DateListQ] && VectorQ[datePriceList[[All,1]], DateListQ] := ...  5 added 52 characters in body edited Oct 19 '13 at 5:34 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  Convert[quantities_, prices_] /; Length[quantities] == Length[prices] := ...  Since DateList returns a list of Length 6 and the first five elements have Head Integer while the last has Head Real you can write your own DateListQ. Here is a head start:  DateListQ[lis_List] := Length[lis] == 6 && VectorQ[Most[lis], IntegerQ] && Head[Last[lis]] == Real  But note that this is an example and if you're inputting your DateList by hand and the last element is also an Integer then you can simply use: DateListQ[lis_List] := Length[lis] == 6 && VectorQ[lis, IntegerQ]  Now you can do something like:  Convert[dateQuantityList_, datePriceList_] /; Length[dateQuantityList] == Length[datePriceList] && VectorQ[Map[DateListQ, dateQuantityList[[All, 1]], {1}], TrueQ] && VectorQ[Map[DateListQ, datePriceList[[All, 1]], {1}], TrueQ] := ...  4 added 227 characters in body edited Oct 19 '13 at 5:17 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges 3 added 227 characters in body edited Oct 19 '13 at 5:09 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges 2 added 321 characters in body edited Oct 19 '13 at 4:50 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges 1 answered Oct 19 '13 at 4:35 RunnyKine 29.4k33 gold badges9595 silver badges166166 bronze badges