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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:41:32+00:00 2026-05-26T15:41:32+00:00

I have the first matrix which should account for each users (in lines) which

  • 0

I have the first matrix which should account for each users (in lines) which products (in columns) they like.
Let’s take 3 users and 5 products.
No user liked a product, so my matrix ILike equals a nul matrix :

let matrixILike = [[0.; 1.;2.;3.]
                   [1.;0.;0.;0.]
                   [2.;0.;0.;0.]
                   [3.;0.;0.;0.]
                   [4.;0.;0.;0.]
                   [5.;0.;0.;0.]]

Now user 1 likes product 2 and user 3 likes product 5 which can be summarized in the following matrix:

let matrixAction = [[1.;2.]
                    [3.;5.]]

So I would like to implement the matrix ILike thanks to the matrixAction to obtain a new updated matrixILike like this :

let matrixILike = [[0.; 1.;2.;3.]
                   [1.;0.;0.;0.]
                   [2.;1.;0.;0.]
                   [3.;0.;0.;0.]
                   [4.;0.;0.;0.]
                   [5.;0.;0.;1.]] 

I try to do this with a “match with” code but it is not working.

for k = 0 to matrixAction.NumRows - 1 do
            match  (matrixAction.[k,0] , matrixAction.[k,1]) with
            | (matrixILike.[x,0] , matrixILike.[0,y]) -> (matrixILike.[x,y] <- 1.)
            | _ -> (matrixILike.[x,y] <- 0.)
matrixILike

If you have any suggestions I take it.

  • 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-26T15:41:33+00:00Added an answer on May 26, 2026 at 3:41 pm

    Without changing your input parameters, this function will do the job.

    let update actions = 
        let mapiTail f = function 
                         | []   -> [] 
                         | h::t -> h :: List.mapi (f h) t
        mapiTail (fun matHead _ ->
            mapiTail (fun rowHead i x -> 
                if List.exists ((=) [matHead.[i+1];rowHead]) actions then 1. else x))
    

    Usage:

    update matrixAction matrixILike
    

    It uses List.mapi which is the same as List.map but with additional parameter: the index.

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

Sidebar

Related Questions

Let's say I have a matrix x which contains 10 rows and 2 columns.
Let's say I have a first structure like this: typedef struct { int ivalue;
I have a list of matrices, the first matrix of which looks as follows:
I have a large matrix from which I would like to randomly extract a
I have my first professional assignment of making a website in which a photographer's
I have a dataframe of 9 columns consisting of an inventory of factors. Each
I would like to build a general matrix module, which includes such general operations
I have a number of spheres in 3d space which the user should be
i have an application which has 3X4 matrix of images using arrow key(up,right,top,bottom) i
I have a 10GB CSV file which is essentially a huge square matrix. I

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.