SlideShare a Scribd company logo
1 of 1
Given vectors u = (u_1, u_2,..., u_n) and v = (v_1, v_2,,..., v_n), the inner product of u and v is
defined to be u_1*v_1 + u_2*v_2 + ... + u_n*v_n. Write a curried F# function inner that takes
two vectors represented as int lists and returns their inner product (assuming the two lists are of
equal length): > inner [1;2;3] [4;5;6];; val it: int = 32
Solution
Answer:)
let rec inner xs ys =
match (xs, ys) with
| ([],[]) -> 0
| ([],ys) -> failwith "Vector dimensions inconsistent"
| (xs,[]) -> failwith "Vector dimensions inconsistent"
| (x::xs, y::ys) -> x*y + inner xs ys
inner [1;2;3] [4;5;6]

More Related Content

More from rtodd588

Graphite bonds in flat sheets with only London forces to hold the shee.docx
Graphite bonds in flat sheets with only London forces to hold the shee.docxGraphite bonds in flat sheets with only London forces to hold the shee.docx
Graphite bonds in flat sheets with only London forces to hold the shee.docxrtodd588
 
Given this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docx
Given this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docxGiven this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docx
Given this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docxrtodd588
 
Growing active lifestyle apparel segment Wholesale distribution mix De.docx
Growing active lifestyle apparel segment Wholesale distribution mix De.docxGrowing active lifestyle apparel segment Wholesale distribution mix De.docx
Growing active lifestyle apparel segment Wholesale distribution mix De.docxrtodd588
 
Group Policy is one of the most useful features of Windows Server 2008.docx
Group Policy is one of the most useful features of Windows Server 2008.docxGroup Policy is one of the most useful features of Windows Server 2008.docx
Group Policy is one of the most useful features of Windows Server 2008.docxrtodd588
 
how can I better understand how to do the reverse in factoring polynom.docx
how can I better understand how to do the reverse in factoring polynom.docxhow can I better understand how to do the reverse in factoring polynom.docx
how can I better understand how to do the reverse in factoring polynom.docxrtodd588
 
Holly inherited $10-000 of City of Atlanta bonds in February- In March.docx
Holly inherited $10-000 of City of Atlanta bonds in February- In March.docxHolly inherited $10-000 of City of Atlanta bonds in February- In March.docx
Holly inherited $10-000 of City of Atlanta bonds in February- In March.docxrtodd588
 
Hi- Please- need help- and step by step- More detail- I need to unders.docx
Hi- Please- need help- and step by step- More detail- I need to unders.docxHi- Please- need help- and step by step- More detail- I need to unders.docx
Hi- Please- need help- and step by step- More detail- I need to unders.docxrtodd588
 
hich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docx
hich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docxhich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docx
hich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docxrtodd588
 

More from rtodd588 (8)

Graphite bonds in flat sheets with only London forces to hold the shee.docx
Graphite bonds in flat sheets with only London forces to hold the shee.docxGraphite bonds in flat sheets with only London forces to hold the shee.docx
Graphite bonds in flat sheets with only London forces to hold the shee.docx
 
Given this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docx
Given this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docxGiven this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docx
Given this information about activity 3-4- ES - 10- EF - 15- LS - 16-.docx
 
Growing active lifestyle apparel segment Wholesale distribution mix De.docx
Growing active lifestyle apparel segment Wholesale distribution mix De.docxGrowing active lifestyle apparel segment Wholesale distribution mix De.docx
Growing active lifestyle apparel segment Wholesale distribution mix De.docx
 
Group Policy is one of the most useful features of Windows Server 2008.docx
Group Policy is one of the most useful features of Windows Server 2008.docxGroup Policy is one of the most useful features of Windows Server 2008.docx
Group Policy is one of the most useful features of Windows Server 2008.docx
 
how can I better understand how to do the reverse in factoring polynom.docx
how can I better understand how to do the reverse in factoring polynom.docxhow can I better understand how to do the reverse in factoring polynom.docx
how can I better understand how to do the reverse in factoring polynom.docx
 
Holly inherited $10-000 of City of Atlanta bonds in February- In March.docx
Holly inherited $10-000 of City of Atlanta bonds in February- In March.docxHolly inherited $10-000 of City of Atlanta bonds in February- In March.docx
Holly inherited $10-000 of City of Atlanta bonds in February- In March.docx
 
Hi- Please- need help- and step by step- More detail- I need to unders.docx
Hi- Please- need help- and step by step- More detail- I need to unders.docxHi- Please- need help- and step by step- More detail- I need to unders.docx
Hi- Please- need help- and step by step- More detail- I need to unders.docx
 
hich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docx
hich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docxhich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docx
hich is most solo ble ethane - ethamol2 butane ar butanal2 SolutionAlk.docx
 

Recently uploaded

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 

Recently uploaded (20)

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 

Given vectors u - (u_1- u_2----- u_n) and v - (v_1- v_2------ v_n)- th.docx

  • 1. Given vectors u = (u_1, u_2,..., u_n) and v = (v_1, v_2,,..., v_n), the inner product of u and v is defined to be u_1*v_1 + u_2*v_2 + ... + u_n*v_n. Write a curried F# function inner that takes two vectors represented as int lists and returns their inner product (assuming the two lists are of equal length): > inner [1;2;3] [4;5;6];; val it: int = 32 Solution Answer:) let rec inner xs ys = match (xs, ys) with | ([],[]) -> 0 | ([],ys) -> failwith "Vector dimensions inconsistent" | (xs,[]) -> failwith "Vector dimensions inconsistent" | (x::xs, y::ys) -> x*y + inner xs ys inner [1;2;3] [4;5;6]