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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:00:52+00:00 2026-06-10T13:00:52+00:00

Is there a way to return an object used in a lambda expression, but

  • 0

Is there a way to return an object used in a lambda expression, but with a different value? I’ve been using the “kind of linq-select” way, but I’d like to do something like this:

let bob= tab 
|> Seq.map (fun x -> ignore (x.Value=x.Value+1); x)
|> Seq.iter (fun x -> x.Dump())

making all the x‘s in my sequence to have their value +1’ed.

instead of doing this:

let bob= tab 
|> Seq.map (fun x -> Ville(IdVille= 9, NoVille=x.Value+1, Nom=x.Nom, __RowVersion = x.__RowVersion))
|> Seq.iter (fun x -> x.Dump())

edit:

What I expect to get : from this, a dump of the sequence, hence the Iter and Dump…
What I want the sequence to be? Here is an example, well the original sequence, but after applying a function to each element and get a copy of the result… (No side effect on the original sequence).

For example, I have a sequence of names, I’d like to have a copy of the original sequence, but with upper-cased names. Now imagine the same, but with a sequence of objects got from a database.

Edit2:

I made a test with LinqPad and AdventureWorks database, and I did this:

let dc = new TypedDataContext()

let tab = dc.GetTable<Address>()

let bob = tab 
        |> Seq.map (fun x -> ignore (x.AddressLine1 <- "Bob"); x) 

tab.Dump()
bob.Dump()

The 2 Dump() results are differents. If I invert the 2 Dump() calls, both results are the same. You were right!

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

    It’s hard to tell what you’re trying to do, but mutating a value suggests an imperative approach, so why not a for loop?

    for x in tab do
      x.Value <- x.Value + 1
      x.Dump()
    

    What value do you expect for bob? Seq.iter returns unit. If you mutate tab within Seq.map it will have the same value as bob.

    EDIT

    If you modify elements of a sequence within map the result and the original sequence will be one and the same. map is not intended to be used with side effects. An example:

    type T(value) =
      member val Value = value with get, set
    
    let tab = [T(0); T(1); T(3)]
    let bob = tab |> Seq.map (fun x -> x.Value <- x.Value + 1; x)
    tab = (Seq.toList bob) //true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to return a CSS element? I was using Adobe Edge
Is there a way to return a random row from a table using LINQToSQL?
Is there a way to dynamically create an object using a string as the
I'm wondering if there's a way to return an object instead of a string
Is there a way to return all the columns in a MySQL table in
Is there any way to return an array from a function? More specifically, I've
Is there a way to return a point for a string within a text
Is there a way to return a new version of an array/hash that does
Is there a (simple) way to return the amount of elements colliding with a
I would like to know if there is any way to return an char

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.