Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:58:41+00:00 2026-06-07T03:58:41+00:00

I define a point type TimeSeriesPoint<‘T> = { Time : DateTimeOffset Value : ‘T

  • 0

I define a point

type TimeSeriesPoint<'T> = 
    { Time : DateTimeOffset
      Value : 'T }

and a series

type TimeSeries<'T> = TimeSeriesPoint<'T> list

where I assume the points in this list are ordered by time.

I am trying to zip two time series, where, in general, they will have points with the same time, but there might be some points missing in either of them.

Any idea why I get a warning for incomplete pattern matches in the code below?

let zip (series1 : TimeSeries<float>) (series2 : TimeSeries<float>) =
    let rec loop revAcc ser1 ser2 =
       match ser1, ser2 with
       | [], _ | _, [] -> List.rev revAcc
       | hd1::tl1, hd2::tl2 when hd1.Time = hd2.Time ->
           loop ({ Time = hd1.Time; Value = (hd1.Value, hd2.Value) }::revAcc) tl1 tl2
       | hd1::tl1, hd2::tl2 when hd1.Time < hd2.Time ->
           loop revAcc tl1 ser2
       | hd1::tl1, hd2::tl2 when hd1.Time > hd2.Time ->
           loop revAcc ser1 tl2
    loop [] series1 series2

If I write it this way, I get no warning, but is it tail recursive?

let zip' (series1 : TimeSeries<float>) (series2 : TimeSeries<float>) =
    let rec loop revAcc ser1 ser2 =
       match ser1, ser2 with
       | [], _ | _, [] -> List.rev revAcc
       | hd1::tl1, hd2::tl2 ->
           if hd1.Time = hd2.Time then
               loop ({ Time = hd1.Time; Value = (hd1.Value, hd2.Value) }::revAcc) tl1 tl2
           elif hd1.Time < hd2.Time then
               loop revAcc tl1 ser2
           else 
               loop revAcc ser1 tl2
    loop [] series1 series2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:58:42+00:00Added an answer on June 7, 2026 at 3:58 am

    In general, it is an anti-pattern to have a when guard in the last pattern.

    In zip, you can achieve the same effect as zip' does by removing the redundant guard:

    let zip (series1: TimeSeries<float>) (series2: TimeSeries<float>) =
        let rec loop revAcc ser1 ser2 =
           match ser1, ser2 with
           | [], _ | _, [] -> List.rev revAcc
           | hd1::tl1, hd2::tl2 when hd1.Time = hd2.Time ->
               loop ({ Time = hd1.Time; Value = (hd1.Value, hd2.Value) }::revAcc) tl1 tl2
           | hd1::tl1, hd2::tl2 when hd1.Time < hd2.Time ->
               loop revAcc tl1 ser2
           | hd1::tl1, hd2::tl2 ->
               loop revAcc ser1 tl2
        loop [] series1 series2
    

    Both two functions are tail recursive since there is no extra work after a recursive call to loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this Define Field(#FLTPOINT) Type(*DEC) Length(7) Decimals(0) I'm not sure if
I have defined a variable with an own type, say Dim point As DataPoint
When you define an extension-point in an Ant build file you can have it
I'm trying to define a new URL handler under OSX that will point at
3 points are needed to define a plane. Newell's method is known to fail
This is my header file: /** * Job.h * **/ #ifndef JOB_ #define JOB_
Any ideas as to why this public Collection<Point> data = new Collection<Point>(){ new Point{X=10,Y=20},
What I mean is to define an instance of a type class that applies
How would one define a type for dimensions? Can you define a type in
In the following code sample I define an enum and specify its underlying type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.