Question

1) Describe in your own words the fundamental concept behind declarative programming paradigm 2) Explain what...

1) Describe in your own words the fundamental concept behind declarative programming paradigm

2) Explain what is happening below. Why are these results looking like this? Describe why it is happening in your own words.

>(-10.2 10)

0.1999999999999993

>(-1.2 1)

0.1999999999999996

>(-1.4 1)

0.3999999999999999

>(-2.2 1)

1 .2000000000000002

3)Below is a scheme function. for your answer, write a comment for this piece of code in valid scheme syntax

(define( factorial n)

if(=n 0)

1

(*n(factorial(-n 1)))))

The elements to include in your comment that is described in your own words(succinctly, such as if you were commenting code instead of a survey)

1) the necessary formatting to indicate it is a legal scheme comment

2) expected input

3) expected output

4) what is the purpose of this function

4) How can you implement iteration (such as checking if there are any even elements in a linked list) in a purely functional language, when there's no loop variable concept?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

This is a very big question.
I have solved all of them.
Please give me an upvote dear, Much Appreciated.!!

  1. The fundamental concept behind the declarative programming paradigm is:
    • The declarative Programming languages always describe the desired end result rather than outlining all the intermediate work steps.
    • It actually has What has to be done instead of How it is done.
    • Examples of programming languages that follow the declarative programming paradigm are:
      • F#
      • Haskell
      • Scheme
      • Prolog
      • Lisp etc.,
  2. .Given results are:

    • >(-10.2 10) has produced the result 0.1999999999999993 but NOT 0.2.

    • (-1.2 1) has produced the result 0.1999999999999996 but NOT 0.2 and so on

      • The reason behind all these is "Floating Point Precision"

      • Here, we have a float value like 10.2, it is actually stored in the system as 10.19999999999999999999...

      • It is because we have to store the float number in the IEEE format.

      • When we perform a subtraction operation, we will lose this precision and get these results.

  3. Code: Please note that anything after a colon is a comment ; THIS IS COMMENT

    • SOURCE CODE:

      *Please follow the comments to better understand the code.

      **Please look at the Screenshot below and use this code to copy-paste.

      ***The code in the below screenshot is neatly indented for better understanding.

    • ; declare the function here

      (define (factorial n)

      ; check the condition if n value is less than 0

      (cond ((< n 0) )

      ((<= n 1) 1) ; If the condition is true, return 1

      (else (* n (factorial (- n 1)))))) ; Else call the function recursively.

      ; This function will calculate the FACTORIAL of the number

      ; Example:

      ; 5! = 5*4*3*2*1 = 120

      ; 6! = 6*5*4*3*2*1 = 720 and so on

    • Code screenshot:-

INPUT and OUTPUT

4. It will calculate the Factorial of a number.

If there are any doubts, comment down here. We are right here to help you. Happy Learning..!! PLEASE give an UPVOTE I Have Pu

Add a comment
Know the answer?
Add Answer to:
1) Describe in your own words the fundamental concept behind declarative programming paradigm 2) Explain what...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT