Question

I am writing SML program to update records in a list.For example, I have type person_name. type ...

I am writing SML program to update records in a list.For example, I have type person_name.

type person_name = {fname:string, lname:string, mname:string}

Then I have person_bio which has person_name embedded in it.

type person_bio = {age:real, gender:string, name:person_name, status:string}

Next I have employee which has person_bio.

type employee = {p:person_bio, payrate:real, whours:real} list;

Now, I have to define function 'updateLastName' by passing the first name.

As of now, created one record 'e1' with below data.

{p={age=40.0,gender="M",name{fname="rob",lname="sen",mname=""},status="M"},
  payrate=30.0,whours=10.0} 

But I am facing challenge to traverse the list and then updating one field in record.

fun updateLastName(x:string,l:employee)=
  if (L=[]) then []
  else if (x= #fname(#name(#p hd l))  //cheking name of 1st record in list

  //not getting how to update,this kind of line did not work
  #fname(#name(#p hd l) = "abc"

  else updateLastName(x,tl(l));    // hope this is right

Please suggest.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

you can implement following approach to get update record

updateLastName {x ="exiting name", b = "you want to update that name"}

it will works.

Add a comment
Know the answer?
Add Answer to:
I am writing SML program to update records in a list.For example, I have type person_name. type ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • There is a problem in the update code. I need to be able to update one...

    There is a problem in the update code. I need to be able to update one attribute of the students without updating the other attributes (keeping them empty). package dbaccessinjava; import java.sql.DriverManager; import java.sql.Connection; import java.sql.SQLException; import java.sql.*; import java.io.*; import java.util.Scanner; public class DBAccessInJava { public static void main(String[] argv) {    System.out.println("-------- Oracle JDBC Connection Testing ------"); Connection connection = null; try{ Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con= DriverManager.getConnection("jdbc:oracle:thin:@MF057PC16:1521:ORCL", "u201303908","pmu"); String sql="select * from student"; Statement st; PreparedStatement ps; ResultSet rs;...

  • I am trying to search a name on a list and then remove it by invoking...

    I am trying to search a name on a list and then remove it by invoking the remove function. However when I search for the name it keeps on saying name not found. What am I doing wrong? (The instruction is in the comments) The remove and drop(delete) coding I have so far is below. void buddyList::remove(buddy * r) { buddy * b4 = head; if (r == head) head = head->next; else { while (b4->next != r) { b4...

  • Hello, I am trying to get this Array to show the summary of NETPAY but have...

    Hello, I am trying to get this Array to show the summary of NETPAY but have been failing. What is wrong? #include <iostream> #include <iomanip> using namespace std; main(){ char empid[ 100 ][ 12 ];    char fname[ 100 ][ 14 ], lastname[ 100 ][ 15 ];    int sum; int hw[ 100 ]; double gp[ 100 ], np[ 100 ], hr[ 100 ], taxrate[100], taxamt[ 100 ]; int counter = 0; int i; cout<<"ENTER EMP ID, FNAME, LNAME, HRS...

  • I have created an HTML form. I need to connect this to a database to update...

    I have created an HTML form. I need to connect this to a database to update the phone number in the employee table HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> </head> <body link="#0000EE" vlink="#551A8B" text="#000000" bgcolor="#566573" alink="#EE0000" background="../DOC/brushed-alum.png"> <form method="post" action="phonenumbers.php"> <h1>Update Employee Phone Number Form</h1> <br> <br> <h3>Enter the employee's ID number.</h3> <br> <br> Employee ID Number: <input name="EmployeeNumber" type="text"> <br> <br> <h3>Enter the new phone number</h3> Phone Number: <input name="OfficePhone" type="text">...

  • The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried t...

    The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...

  • I am currently facing a problem with my python program which i have pasted below where...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • I am trying to modify this program so that it stores the employee's name in a...

    I am trying to modify this program so that it stores the employee's name in a c-string and can handle up to 100 employees (so it would mostly be a partially filled array), but I cannot get it to work. It works with two files that it is suppose to read input from. Then it prints output to an output file. Employee Info File (first file read, M/F should be ignored): 5    Christine Kim 30.00   2       1    F 15    Ray...

  • I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • I am creating a program that will allow users to sign in with a username and...

    I am creating a program that will allow users to sign in with a username and password. Their information is saved in a text file. The information in the text file is saved as such: Username Password I have created a method that will take the text file and convert into an array list. Once the username and password is found, it will be removed from the arraylist and will give the user an opportunity to sign in with a...

  • Suppose i have one input type textbox for example Bday :<div id="clickbox">               ...

    Suppose i have one input type textbox for example Bday :<div id="clickbox">                                        <input name="bday" size="10" maxlength="10" class="TextInput"                                            value="${bday}" onchange="validatedate(this)"/>                                            <img src="/LMS/img/calendar.gif" border="0" onclick="openCalWin_actual_date('0', 'bday');" /> </div>                                    </td> ======================================================= On clicking the Calendar icon i am able to open the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT