;; your task is to fill in the code for the reply function ;; to implement rules
ID: 3812853 • Letter: #
Question
;; your task is to fill in the code for the reply function
;; to implement rules 1 through 11 with the required priority
;; each non-trivial rule must be implemented in a separate function
;; define any helper functions you need below
;; rule 11 has been implemented for you
(define (reply input name)
(output (pick-random generic-response)))
Rule 1:
input is of the form: (do|can|will|would) you ________________?
response (randomly chosen): no <name> i (do|can|will|would) not __change person___ yes i (do|can|will|would)
Rule 2:
input: _____(special topics)_______ tell me more about your (special topics)...
response: <name>
Rule 3:
input: why __________?
response: why not?
Rule 4:
input: how __________?
response: why do you ask? or how would an answer to that help you?
Rule 5:
input: what __________?
response: why do you ask? or what do you think?
Rule 6:
input: _____________?
response: i don't know | i have no idea | i have no clue | maybe
Rule 7:
input: ______because_______
response: is that the real reason?
Rule 8:
input: i (need|think|have|want) _____
response: why do you (need|think|have|want)__change person_____?
Rule 9:
input: i _________ (last word not too)
response: i __________ too
Rule 10:
input: verb ________________
response: you verb ______________
Rule 11:
input: everything else
response: good to know / that's nice / can you elaborate on that?
;;; starter code
;;; We'll use the random function implemented in Racket
;;; (random k) returns a random integer in the range 0 to k-1
(#%require (only racket/base random))
;;; some input and output helper functions
;;; prompt: prompt the user for input
;;; return the input as a list of symbols
(define (prompt)
(newline)
(display "talk to me >>>")
(read-line))
;;; read-line: read the user input till the eof character
;;; return the input as a list of symbols
(define (read-line)
(let ((next (read)))
(if (eof-object? next)
'()
(cons next (read-line)))))
;;; output: take a list such as '(how are you?) and display it
(define (output lst)
(newline)
(display (to-string lst))
(newline))
;;; to-string: convert a list such as '(how are you?)
;;; to the string "how are you?"
(define (to-string lst)
(cond ((null? lst) "")
((eq? (length lst) 1) (symbol->string (car lst)))
(else (string-append (symbol->string (car lst))
" "
(to-string (cdr lst))))))
;;; main function
;;; usage: (chat-with 'your-name)
(define (chat-with name)
(output (list 'hi name))
(chat-loop name))
;;; chat loop
(define (chat-loop name)
(let ((input (prompt))) ; get the user input
(if (eqv? (car input) 'bye)
(begin
(output (list 'bye name))
(output (list 'have 'a 'great 'day!)))
(begin
(reply input name)
(chat-loop name)))))
;;; your task is to fill in the code for the reply function
;;; to implement rules 1 through 11 with the required priority
;;; each non-trivial rule must be implemented in a separate function
;;; define any helper functions you need below
(define (reply input name)
(output (pick-random generic-response))) ; rule 11 has been implemented for you
;;; pick one random element from the list choices
(define (pick-random choices)
(list-ref choices (random (length choices))))
;;; generic responses for rule 11
(define generic-response '((that's nice)
(good to know)
(can you elaborate on that?)))
Explanation / Answer
import java.io.*;
class LRU
}
return temp;
}
public static void main(String args[])throws IOException the dimensions of the array”);
int n=Integer.parseInt(br.readLine());
int a[]=new int[n];
int flag[]=new int[n];
System.out.println(“enter the elements”);
for(int i=0;i<n;i++)
int b[]=new int[3];
int c[]=new int[3];
for(int i=0;i<3;i++)
for(int i=0;i<n;i++)
}
if (flag[i]==0 && b[2]==-1)
}
}
if(flag[i]==0)
}
System.out.println(“no of hits”+hit);
System.out.println(“no of faults”+faults);
System.out.println(“hit ratio”+(hit*100)/(hit+faults));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.