Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please this is an urgent.. I need help doing all the following (or at least what

ID: 3780040 • Letter: P

Question

Please this is an urgent.. I need help doing all the following (or at least what you can do),, thanks

1. (32 points) 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. (a) Function numof takes a value and a list and returns the number of occurrences of the value in the list (b) Function ellen takes a list of character strings and returns a list of the lengths of the corresponding strings. (c) Function ssp takes a list of integers and returns the sum of the squares of the positive elements of the list. (d) 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 ++;} })

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 2 and 3. Answer is displayed as Alert