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 127529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:29:28+00:00 2026-05-11T05:29:28+00:00

I am trying to create a sequence lazily by using F#. The sequence is

  • 0

I am trying to create a sequence lazily by using F#.

The sequence is defined as follows:

The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …

Here is what I have so far but it dosn’t seem to work:

let tri_seq = 1.0 |> Seq.unfold (fun x -> match x with                                                                                    | _ -> Some (x, 0.5*x*(x + 1.0))) 

Thank you very much who can help me figure out how unfold works. Thanks

Edit: I marked the first answer as correct but it dosnt work, however I slightly modified it and it worked.

let tri_seq = 1.0 |> Seq.unfold (fun x -> Some (0.5 * x * (x + 1.0),x + 1.0)) 
  • 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. 2026-05-11T05:29:28+00:00Added an answer on May 11, 2026 at 5:29 am

    First off, why do you use match if you’ve got only one case?

    let tri_seq = 1.0 |> Seq.unfold (fun x -> Some (x, 0.5 * x * (x + 1.0))) 

    Second, what “doesn’t seem to work”? Are you aware that you produce an infinite list?

    /Edit: For completeness’ sake, here’s the correct solution, which the OP found himself and posted as a comment:

    let tri_seq =      1.0 |> Seq.unfold (fun x -> Some (0.5 * x * (x + 1.0), x + 1.0)) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok so I am trying create a login script, here I am using PHP5
Learning clojure, trying to create a lazy infinite sequence of all prime numbers. I'm
Complete Haskell newbie here, my apologies.... I am trying to create a sequence of
I'm trying to create a possible list of codons given a protein sequence. Basically,
I am trying to create a sequence in oracle sql, using the minvalue as
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create my first iPhone app that would play back audio. When I
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
I have Oracle 10gR2. I am trying to create autoincrement trigger. Here is the
I'm trying to create stored procedure in MySQL Community Server 5.5.16: CREATE UNIQUE SEQUENCE

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.