Question

In lisp How can you print the dot product of two lists but return another list...

In lisp

How can you print the dot product of two lists but return another list
if they are not equal in length? not an error message but an actual list of words e.g
return '(Not the same length)

I keep getting a message not a number, no matter what I try.

Homework Answers

Answer #1
(defun dot-product (a b)
  (cond ((null a) (if (null b) 0 (error "Not the same length")))
        ((null b) (error "Not the same length"))
        (t (+ (* (first a) (first b))
              (dot-product (rest a) (rest b))))))
(setq mystring "This is . a . mixed string__ of character$$")
(setq nocharacters (vl-list->string
                 (vl-remove-if
                   '(lambda (x)
                      (member x '(97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90))
                    )
                   (vl-string->list mystring)
                 )
               )
)

Hope this helps you. For anymore queries kindly add comment. Please give an up vote. Thank you.

Know the answer?
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
Similar Questions
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question....
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question. Thank you! Here’s the contents of a file called example.cpp: // example.cpp #include "LinkedList.h" #include <iostream> #include <string> using namespace std; int main() { cout << "Please enter some words (ctrl-d to stop):\n"; LinkedList lst; int count = 0; string s; while (cin >> s) { count++; lst.add(remove_non_letters(s)); } // while cout << "\n" << count << " total words read in\n"; cout <<...
Use python language please #One of the early common methods for encrypting text was the #Playfair...
Use python language please #One of the early common methods for encrypting text was the #Playfair cipher. You can read more about the Playfair cipher #here: https://en.wikipedia.org/wiki/Playfair_cipher # #The Playfair cipher starts with a 5x5 matrix of letters, #such as this one: # # D A V I O # Y N E R B # C F G H K # L M P Q S # T U W X Z # #To fit the 26-letter alphabet into...
Please can someone summarize the content below? Thank you. Medications Work Differently In Older Adults Print...
Please can someone summarize the content below? Thank you. Medications Work Differently In Older Adults Print FacebookTwitterLinkedInEmail Medication dose, as well as information about the effectiveness and side effects of medication, are generally determined by studies done in relatively young, healthy people. This information may not apply to older adults, because our bodies and how we process medications change with age. As we get older, our bodies react to drugs differently than when we were younger. The aging process, along...
Data Structure in C++ I keep getting the same warning, and I cant seem to fix...
Data Structure in C++ I keep getting the same warning, and I cant seem to fix it.. Can you explain to me what I am doing wrong? Warning: dlist.cc: In function 'std::ostream& operator<<(std::ostream&, dlist&)': dlist.cc:66:10: error: invalid initialization of reference of type 'std::ostream& {aka std::basic_ostream&}' from expression of type 'dlist::node*' dlist.cc: In function 'dlist operator+(dlist&, dlist&)': dlist.cc:93:8: error: invalid operands of types 'dlist::node*' and 'dlist::node*' to binary 'operator+' dlist.cc:97:8: error: could not convert 'result' from 'int' to 'dlist' My code:...
**[70 pts]** You will be writing a (rather primitive) online store simulator. It will have these...
**[70 pts]** You will be writing a (rather primitive) online store simulator. It will have these classes: Product, Customer, and Store. All data members of each class should be marked as **private** (a leading underscore in the name). Since they're private, if you need to access them from outside the class, you should do so via get or set methods. Any get or set methods should be named per the usual convention ("get_" or "set_" followed by the name of...
1. Use a tree diagram to show, or list, all possible outcomes when you toss a...
1. Use a tree diagram to show, or list, all possible outcomes when you toss a coin 3 times. 2. Licence plates consist of either 3 letters and 3 numbers or 4 letters and 3 numbers. How many different licence plates can be issued? 3a)      In how many ways can a committee of three be selected from 12 students? b) In how many ways can a president, secretary, and treasurer be chosen from 12 students? 4. How many ways...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
Hello, can you teach me how to draw a Use Case diagram for this given scenario?...
Hello, can you teach me how to draw a Use Case diagram for this given scenario? I also need to include all the extends and includes relationships. Case Description Acme Drug Stores (ADS) which consists of a chain of retail stores across Canada wants to be able to provide a new online customer service system. Each store has an identifying store no, address, phone, and email. The company dispenses a wide range of pharmaceutical (drug) products. Each product has a...
Item Chapter 5 Planning Programs that Prevent Discipline Problems Quote of the Day #1: You can...
Item Chapter 5 Planning Programs that Prevent Discipline Problems Quote of the Day #1: You can discover more about a person in an hour of play than in a year of conversation. Plato This chapter focuses on planning programs that prevent discipline problems. I consider myself a "constructivist teacher". I think students learn best when the information is meaningful to them and the process engages their curiosity and exploration. I want to encourage students to explore ideas and develop them,...