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...
How to measure the time complexity of an algorithm? Identify an important operation in the algorithm...
How to measure the time complexity of an algorithm? Identify an important operation in the algorithm that is executed most frequently. Express the number of times it is executed as a function of N. Convert this expression into the Big-O notation. A. For each of the three fragments of code, what is its worst-case time complexity, in the form "O(…)". (Use the given solution to the first problem as a model)                 //----------------- This is a sample problem – solved ------...
For this discussion, you will demonstrate to the class how you break down a primary source....
For this discussion, you will demonstrate to the class how you break down a primary source. Historians break down primary sources in very methodical ways. Using Japanese internment and Women and the home front WWII primary source excerpts from our activities this week. I would like you to record yourself (either video, audio only, or written script) breaking down the primary source in a 2 minute or less presentation. How to Analyze a Primary Source When you analyze a primary...
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...