This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@page import="javax.servlet.ServletContext" %> | |
<%@page import="javax.servlet.RequestDispatcher" %> | |
<% | |
ServletContext servletcontext = pageContext.getServletContext(); | |
ServletContext servletcontext1 = servletcontext.getContext("/testAPP/v/a.jsp"); | |
if (servletcontext1 != null) { | |
out.println("SC is not null"); | |
RequestDispatcher requestdispatcher = servletcontext1.getRequestDispatcher("/v/a.jsp"); | |
if (requestdispatcher != null){ | |
out.println("RD is not null"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<style type="text/css"> | |
body{background-color:#ccc} | |
#box{ | |
width:100px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Print the string “Hello, world.” | |
puts 'Hello, world' | |
# For the string “Hello, Ruby,” find the index of the word “Ruby.” | |
'Hello, Ruby.'.index('Ruby') | |
# Print your name ten times | |
10.times do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Print the contents of an array of sixteen numbers, four numbers | |
at a time, using just each. | |
=end | |
i=0 | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16].each do |x| | |
i=i+1 | |
print "#{x} " | |
puts "" if i%4==0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Modify the CSV application to support an each method to return a | |
CsvRow object. Use method_missing on that CsvRow to return the value | |
for the column for a given heading. | |
For example, for the file: | |
one, two | |
lions, tigers | |
allow an API that works like this: | |
csv = RubyCsv.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Evaluate 1 + 1 and then 1 + "one". Is Io strongly typed or weakly typed? Support your answer with code. | |
// It seems strongly typed to me | |
1+1 | |
// ==> 2 | |
1+"one" | |
// Exception: argument 0 to method '+' must be a Number, not a 'Sequence' | |
// --------- | |
// message '+' in 'Command Line' on line 1 | |
// But you can do think like this | |
Vehicle := Object clone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Fibonacci sequence starts with two 1s. Each subsequent number | |
// is the sum of the two numbers that came before: 1, 1, 2, 3, | |
// 5, 8, 13, 21, and so on. Write a program to find the nth Fibonacci | |
// number. fib(1) is 1, and fib(4) is 3. As a bonus, solve the problem | |
// with recursion and with loops. | |
fib := method(a, if(a==1, 1, if (a==2, 1, fib(a-1)+fib(a-2)))) | |
fib(15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Builder := Object clone | |
Builder addIndent := method( | |
for(i, 1, indent*2, " " print) | |
) | |
Builder indent := 0 | |
Builder forward := method( | |
self addIndent | |
writeln("<", call message name, ">") | |
indent = indent +1 | |
call message arguments foreach( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Make a simple knowledge base. Represent some of your favorite | |
% books and authors. | |
author(apprenticeship, dave_hoover). | |
author(getting_real, jason_fried). | |
author(rework, jason_fried). | |
% Find all books in your knowledge base written by one author. | |
author(Book, jason_fried). | |
% Make a knowledge base representing musicians and instruments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Some implementations of a Fibonacci series and factorials. How | |
% do they work? | |
% La sintaxis es factorial(N, F) -> Factorial de N es F (el resultado se guarda en F) | |
factorial(0, 1). | |
factorial(N, F) :- N>0, N1 is N - 1, factorial(N1, F1), F is N*F1. | |
%el factorial se llama recursivamente dejando el resultado en F |
OlderNewer