Euphoria Programming Language Interview Questions & Answers

  1. Question 1. Is There A Tool To Help Find Bugs Or Perform Static Analysis?

    Answer :

    TEST (all) Parses the code only and issues any warnings or errors to STDOUT. On error the exit code will be 1, otherwise 0. If an error was found, the normal “Press Enter” prompt will not be presented when using the -TEST parameter which enables many editor/IDE programs to test the syntax of your Euphoria source in real time.

  2. Question 2. How Do You Set A Global Variable In A Function?

    Answer :

    Assign a value to it.

  3. Principles of Programming Languages Interview Questions

  4. Question 3. How Do I Share Global Variables Across Modules?

    Answer :

    Use the “global” variable definition.

  5. Question 4. How Do I Write A Function With Output Parameters (call By Reference)?

    Answer :

    Euphoria doesn’t support call by reference. If you want your function to modify a variable, assign the return value of the function to that variable.

  6. Go (programming language) Tutorial

  7. Question 5. How Do I Copy An Object In Euphoria?

    Answer :

    a=b

  8. Mac OS X Deployment Interview Questions

  9. Question 6. How Can I Find The Methods Or Attributes Of An Object?

    Answer :

    Euphoria isn’t object oriented.

  10. Question 7. How Can My Code Discover The Name Of An Object?

    Answer :

    Euphoria isn’t an object oriented language.

  11. D Programming Language Tutorial
    Go (programming language) Interview Questions

  12. Question 8. How Do I Specify Hexadecimal And Octal Integers?

    Answer :

    For hexadecimal, use the ‘#’ symbol (#FE, #A000, etc.). It is not possible to input octal values, but it is possible to output them. See printf().

  13. Question 9. How Do I Convert A String To A Number?

    Answer :

    Use the value() function.

  14. Berkeley Software Distribution (BSD) Interview Questions

  15. Question 10. How Do I Convert A Number To A String?

    Answer :

    Use the sprint() orsprintf() function.

  16. Lua (programming language) Tutorial

  17. Question 11. How Do I Modify A String In Place?

    Answer :

    Just do it. name = “Abe Lincoln” name = “Abraham Lincoln”

  18. D Programming Language Interview Questions

  19. Question 12. How Are Arguments Passed?

    Answer :

    All arguments are passed by value.

  20. Principles of Programming Languages Interview Questions

  21. Question 13. Does The Value Of A Constant Ever Change?

    Answer :

    No. The value of a constant is fixed when it’s defined for the life of the program.

  22. Question 14. Does Euphoria Support Keyword Arguments?

    Answer :

    No. There are ways to simulate keyword arguments, however, using functions in the std library.

  23. Question 15. What Does $ Mean?

    Answer :

    The symbol ‘$’ in Euphoria version 2.5 and later means “length(of_sequence).”

    sequence s, i  
    s = “My Sequence”  
    i = s[$] — i = “e”  
    i = s[4..$] — i = “Sequence”  
    i = s[$-5] — i = “q” 

  24. Lua (programming language) Interview Questions

  25. Question 16. Does Euphoria Have Exception Handling?

    Answer :

    No.

  26. Question 17. What’s A Negative Index?

    Answer :

    Negative index is a mis-named feature of Python and some other languages. If the index is n, and n = -1, then this means, to python, in English, “the last”. In Euphoria, this would be x[length(x)], or in a more convenient shorthand x[$]. In Python, -2 would mean “next to last”. In Euphoria x[length(x)-1] or x[$-1].

  27. Advanced Linux Interview Questions

  28. Question 18. How Do I Iterate Over A Sequence In Reverse Order?

    Answer :

    Use a for..loop, like so

    sequence s  
    for t=length(s) to 1 by -1 do  
        — do something with s[t]  
    end for 

  29. Mac OS X Deployment Interview Questions

  30. Question 19. How Do You Make An Array In Euphoria?

    Answer :

    Sequences are arrays. You create them by first declaring a variable as sequence, then assigning elements to the sequence. For example

    sequence s  
    s = { 1, 2, 3 } — s is a 3-element sequence  
    s = repeat(0,20) — s is a 20-element sequence of zeroes  
    s = repeat(repeat(1,10),20) — s is a 20-element sequence of 10-element sequences 

  31. Question 20. How Do You Refer To Individual Elements In An Array?

    Answer :

    You get the value from a sequence with bracketed values. For instance,

    ?s[5][3] — prints the third element of the fifth sequence (a multi-dimensional sequence)

  32. Win32 Api Interview Questions

  33. Question 21. I Want To Do A Complicated Sort: Can You Do A Schwartzian Transform In Euphoria?

    Answer :

    The term “Schwartzian transform” is the perl name for a sorting algorithm which can be written in almost any turing-complete programming language, including Euphoria. Euphoria is likely to be faster than perl.

  34. Question 22. How Can I Process A File And Update Its Contents?

    Answer :

    One way to do this is:

    1. Use read_lines() to read in the contents of a file.
    2. Manipulate the sequence of lines as desired
    3. Use write_lines() to write the sequence back to a file.
  35. Question 23. Should I Feel Uneasy If I Don’t Close A File?

    Answer :

    You should always close any files you no longer need open. However, Euphoria will automatically close any still-open files when your program terminates.

  36. Dart programming language Interview Questions

  37. Question 24. How Can I Control Output Buffering?

    Answer :

    flush.

  38. Go (programming language) Interview Questions

  39. Question 25. How Can I Use A Library Written In C From Euphoria?

    Answer :

    You can access shared libraries from a Euphoria program.

    You can use code from a shared library uing open_dll(libname). This returns an atom which you’ll have to reuse to access individual variables or functions.

    You can access a function in a previously opened shared library by calling define_c_function(entry_point,func_name,type_arglist,return_type). This return an id that you can use with call_func().

    define_c_proc() and define_c_var() work in the same way, but require less arguments for obvious reasons. You can define a function as a procedure if you’ll never care about the returned value. You can access executable machine code using the above. Use “” as an entry point, and the address as name.

    You can call(address) so that code at address gets executed. The code must be a routine that returns using the near ret instructions (opcode #C3). All used registers must be restored upon return. You’ll have to set up the memory area which you’ll call() into by coding some machine code into a sequence, allocate() a memory block of the right size and poke()ing the sequence first.

    You must be aware that the code will run in 32 bit protected mode at privilege 3, and that call() requires two task switches, penalizing performance unless the asm code has a lot of work to perform. (1)

  40. Question 26. How Can I Count The Number Of Lines In A File?

    Answer :

    Here’s one way:

    include std/io.e 
    sequence fname = “GtkEngine.e” 
    object lines = read_lines(fname) 
    printf(1,”There are %d lines in file %sn”,{length(lines),fname}) 

  41. Question 27. How Can I Sum The Elements In An Array?

    Answer :

    Here’s one way:

    include std/math.e 
    sequence a = {1,2,3,4,5,6,7,8}  
    ? sum(a) 

  42. Berkeley Software Distribution (BSD) Interview Questions

  43. Question 28. Is There A Cgi Module For Euphoria?

    Answer :

    There is no standard CGI module that gets distributed with the Euphoria base package. However, there is code available for doing CGI with Euphoria (obviously, because this entire website is being served by a Euphoria CGI program). You can also get specific information for running Euphoria as CGI here and at the official Euphoria web site.

  44. Question 29. Does Euphoria Support Object Oriented Programming?

    Answer :

    Vanilla Euphoria does not “support” OO programming, though there are OO libraries in the archive, and Matthew Lewis has created a Euphoria interpreter with built-in object-oriented features.

  45. Question 30. Why Does My Program Take Longer To Load?

    Answer :

    Symbol scope and resolution has changed in v4. Most v3 code will work correctly with respect to include files and global symbols, but if you use a global symbol without including the file in which it was defined (or another file that includes the correct file) then euphoria will take a little longer to resolve that reference. It is advised that if you use any variable or routine from some file or library, that each using file include the file or library that defines the symbols being used.