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

  • Home
  • SEARCH
  • 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 8948589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:02:02+00:00 2026-06-15T13:02:02+00:00

What is the proper way to extend the available operators when using RX? I’d

  • 0

What is the proper way to extend the available operators when using RX?

I’d like to build out some operations that I think would be useful.

The first operation is simply the standard deviation of a series.

The second operation is the nth lagged value i.e. if we are lagging 2 and our series is A B C D E F when F is pushed the lag would be D when A is pushed the lag would be null/empty when B is pushed the lag would be null/empty when C is pushed the Lag would be A

Would it make sense to base these types of operators off of the built-ins from rx.codeplex.com or is there an easier way?

  • 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-15T13:02:03+00:00Added an answer on June 15, 2026 at 1:02 pm

    In idiomatic Rx, arbitrary delays can be composed by Zip.

    let lag (count : int) o = 
        let someo = Observable.map Some o
        let delayed = Observable.Repeat(None, count).Concat(someo)        
        Observable.Zip(someo, delayed, (fun c d -> d))    
    

    As for a rolling buffer, the most efficient way is to simply use a Queue/ResizeArray of fixed size.

    let rollingBuffer (size : int) o = 
        Observable.Create(fun (observer : IObserver<_>) -> 
        let buffer = new Queue<_>(size)
        o |> Observable.subscribe(fun v -> 
                buffer.Enqueue(v)
                if buffer.Count = size then
                    observer.OnNext(buffer.ToArray())
                    buffer.Dequeue() |> ignore
            )
        )
    

    For numbers |> rollingBuffer 3 |> log:

    seq [0L; 1L; 2L]
    seq [1L; 2L; 3L]
    seq [2L; 3L; 4L]
    seq [3L; 4L; 5L]
    ...
    

    For pairing adjacent values, you can just use Observable.pairwise

    let delta (a, b) = b - a
    let deltaStream = numbers |>  Observable.pairwise |> Observable.map(delta) 
    

    Observable.Scan is more concise if you want to apply a rolling calculation .

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

Sidebar

Related Questions

Would this be the proper way to extend a structure array? typedef struct {
What is the proper way to guarantee delivery when using a SwingWorker? I'm trying
I'm trying to figure out the proper way to display arrays of objects, indexed
Im starting to build a new app and I would like to use Backbone
We are using WSS 3 SP2. I'd like to preface this by saying that
What would be the proper way to unit test an abstract class which takes
TL;DR Is PinView.prototype = _.extend(PinView.prototype, google.maps.OverlayView.prototype) the proper way to have a Backbone View
I would like to be able to use underscore's extend function and implement a
I was looking a proper way to implment a ScaleAnimation. My purpose is to
What's the proper way to add a literal text value from a field 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.