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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:29:33+00:00 2026-05-24T02:29:33+00:00

How to write records just in time when the value for id of something

  • 0

How to write records just in time when the value for id of something is changing ? id for each record when ture->false and false->true for some list?

for example table

id value
 1 0
 2 0
 2 0
 2 0
 1 0
 2 1 --> the only changes here
 2 1
 1 0
 2 0 --> and here (node with id 2 changed 1 -> 0 )
 1 1 --> node with id 1 changed 0 -> 1     

result table

2 1
2 0
1 1

my idea is not functional and a bit weird, I’m thinking about functional or linq way of making the same.

                        let oop = ref (filteredsq
                                       |> Seq.distinctBy(fun (node,v,k) -> k) 
                                       |> Seq.map(fun (node,v,k) -> k, false )
                                       |> Array.ofSeq )
                        [for (node,value,key) in filteredsq do
                            let i = ref 0
                            for (k,v) in !oop do
                                if key = k && value <> v then
                                    (!oop).[!i] <- (k,value)
                                    yield node
                            i := !i + 1 ]

Thank you

  • 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-05-24T02:29:34+00:00Added an answer on May 24, 2026 at 2:29 am

    I’m not sure if I fully understand your question, but the following gives the right output according to your sample. The idea is to first filter out values that don’t have the right key and then use Seq.pairwaise (as in jpalmer’s solution) to find the places where the value changes:

    let input = [ (1, 0); (2, 0); (2, 0); (2, 0); (1, 0); (2, 1); (2, 1); (1, 0); (2, 0) ]
    
    let findValueChanges key input =
      input 
      |> Seq.filter (fun (k, v) -> k = key) // Get values with the right key
      |> Seq.pairwise                       // Make tuples with previous & next value
      |> Seq.filter (fun ((_, prev), (_, next)) -> prev <> next) // Find changing points
      |> Seq.map snd                        // Return the new key-value pair (after change)
    

    If you wanted to find changes for all different keys, then you could use Seq.groupBy to find all possible keys (then you wouldn’t need the first line in findValueChanges):

    input 
    |> Seq.groupBy fst
    |> Seq.map (fun (k, vals) -> findValueChanges k vals)
    

    (For your input, there are no changes in values for the key 1, because the value is always 1, 0)

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

Sidebar

Related Questions

I need to write a simple program that records all the input from parallel
I'm trying to write a GQL query that returns N random records of a
How would I write a SQLite query to select all records from a specific
I am struggling to write a query to result in the following records. I
I am trying to write a simple correlated sub query that deletes all records
I have an oracle database populated with million records. I am trying to write
I am trying to write a python script that takes record data like this
How would I write a SQL query that excludes a record if one (external)
Basic doubt...If QTP generates vbscript code as we record actions, can't we directly write
I get to dust off my VBScript hat and write some classic ASP to

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.