Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write each of the following pure functions (a function is pure if it does not update any of the arguments or global variables). The actual

image text in transcribed
Write each of the following pure functions (a function is pure if it does not update any of the arguments or global variables). The actual return type List should be the same as the actual type of the parameter List. No functions in the Collections class can be used. 1.1 The function take(n, lst) returns a list that takes n elements from 1st. public static List take(int n, List lst) 1.2 The function drop(n, lst) returns a list that keeps all the elements of lst except for the first n elements. For example, drop(5, (1,2,3,4,5,6,7,8,9,10)) returns (6,7,8,9,10). public static List drop(int n, List lst) 1.3 The function reverse (1st) returns a copy of the list ist with the elements reversed. public static List reverse (List lst) 1.4 The function sortedDown (1st) checks if Ist is sorted in non-increasing order. For exam- ple, for 1st - [3,3,2,1), it returns true. public static > boolean sortedDown (List 1st) 2. Write a program that reads words from a text file and displays all the words (duplicates allowed) in ascending alphabetical order. The text file is passed as a command-line argument

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions