Can anyone do me the following programming.. This is very important and urgent..
ID: 3780042 • Letter: C
Question
Can anyone do me the following programming.. This is very important and urgent.. thanks
For each of the following specifications, write an Elm function that has the given arguments and result. You may use the library functions such as map, filter, and foldr as appropriate. You may also use the instrutor's display output function if you wish. Function numof takes a value and a list and returns the number of occurrences of the value in the list. Function ellen takes a list of character strings and returns a list of the lengths of the corresponding strings. Function ssp takes a list of integers and returns the sum of the squares of the positive elements of the list. Given type Tree a = Leaf I Node a (Tree a) (Tree a) write a function twist takes a tree and returns the tree with every left and right subtree reversed for every node, but otherwise leaves the structure of the tree the same. That is. Node 3 (Node 2 Leaf Leaf) (Node 4 Leaf Leaf) becomes Node 2 (Node 4 Leaf Leaf) (Node 3 Leaf Leaf).Explanation / Answer
// Answer
// 1. Below returns the count of number of occurrance of 'a' in list
var list =
[
{ Name: 'a' },
{ Name: 'b' },
{ Name: 'c' },
{ Name: 'a' },
{ Name: 'b' },
{ Name: 'c' }
];
var count = 0;
$.each(list ,function(ind,elm){ if(elm.Name == 'a'){count ++; alert(count) } })
//See value of count for number of occurrance of 'a' in list
// Answer 2:
var list =
[
{ Name: 'absdf' },
{ Name: 'b' },
{ Name: 'ca' },
{ Name: 'abc' },
{ Name: 'basf' },
{ Name: 'cqw' }
];
for(i=0;i<list.length;i++)
{
alert( (list[i].Name).length)
}
//3 Answer
var list = [
1,2,3,4,5,6
];
for(i=0;i<list.length;i++)
{
if(list[i]>0)
{
alert(list[i]*list[i])
}
}
//Note : for 1, 2 and 3. Answer is displayed as Alert
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.