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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:18:03+00:00 2026-06-10T16:18:03+00:00

type A = { … id: int; … } I wish i could do

  • 0
type A =
  {
    ...
    id: int;
    ...
  }

I wish i could do this

let Add (x:A) (y:A) =
     match x,y with
      | {x.id=0,y.id=1} -> ...

And is there any trick to define the function if i don’t care about the order of x and y (so that the function is symmetric) also i don’t mind whether the parameter is a tuple (x,y) or a higher order function x,y

  • 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-10T16:18:05+00:00Added an answer on June 10, 2026 at 4:18 pm
    let add (x: A) (y: A) =
         match x.id, y.id with
         | 0, 1 | 1, 0 -> (* do some thing *)
         | _ -> (* do some thing else *)
    

    If you only care about a field, do pattern matching directly on it. And you can use Or pattern to have a symmetric function.

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

Sidebar

Related Questions

The type of this function is T -> (T -> U) -> U .
What type define an argument to make sure this is of determinate class and
Please type this in. scala> 86400000 * 150 res0: Int = 75098112 scala> val
# type foo = Foo of int * int # let t = (1,
type(3,) returns the int type, while t = 3, type(t) returns the tuple type.
type TParent=class public member1:Integer; end; TChild=class(TParent) public member2:Integer; end; TGArray<T: TParent>=class public function test:T;
var type = $(this).attr(data-type); var typeId = $(this).attr(data-value); if(type==category) var typeVar=cat; else if(type==subcategory) var
type Foo = class inherit Bar val _stuff : int new (stuff : int)
type Tag(Kids) = member this.Kids = Kids static member (-) (this: Tag, that: list<obj>)
Input type with id 'typehere'. There is a keydown event set on typhere .

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.