Name | Language |
---|---|
Alex Mitchell | Clojure |
Anne McLoughlin | Julia |
Cathal McGovern | Oz |
Conor Fitz | FORTRAN |
Conor Loney | Forth |
Darren Coyle | Elixir |
Fionn Collander | BASIC |
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
--Create functions to do the following: | |
{- Solutions to the questions I gave last week. | |
Note: This is the way I would answer these questions. In Haskell, there | |
are usually many ways to get the same solution, so dont worry if | |
any of your answers are different. If you have a solution that is | |
different, please lete me know. | |
If you have any questions, please ask me. Use the Moodle Forum, the | |
facebook group or the email address I posted on the Facebook page. I am |
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
import java.util.Scanner; | |
public class Temp{ | |
public static void main (String [] args) { | |
Scanner scan = new Scanner(System.in); | |
int n = scan.nextInt(); | |
if (n == 1) {System.out.println("2");} | |
if (n == 2) {System.out.println("4");} | |
if (n == 3) {System.out.println("8");} |
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
module SAP where | |
import Data.Function | |
import Data.List | |
import Data.List.Split | |
import System.IO | |
data Token = Token {colour :: Colour, value :: Int} | |
deriving (Eq) |
The following code takes 6 seconds to run on a DOS box emulator. Calculate the number of clock cycles required for the highlighted code (A) to run?
Ok so for this part you need to count the number of cycles this program will execute. Each comment will tell you how many
cycles each instruction takes. E.g. It takes 4 clock cycles to run mov bx, 100
. On the jump instructions, you will see
something like '16 backward 4 forward', this means if the jump instruction jumps back, it will yake 16 cycles, if it doesn't
jump, it will take 4.
In this example, when cx > 0, jnz back1
will take 16 cycles. But when cx
== 0, it will take 4 cycles.
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
require 'pp' | |
# https://gist.github.com/awesome/3842062 | |
def dirHash(path) | |
Dir["#{path}/**/*"].inject({}) {|h,i| t = h; i.split("/").each {|n| t[n] ||= {}; t = t[n]}; h} | |
end | |
# https://gist.github.com/henrik/146844 | |
def deep_diff(a,b) | |
(a.keys | b.keys).inject({}) do |diff, k| |
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
#! /bin/bash | |
# For one line installation, use the command in the comment on the next line | |
# bash <(curl https://gist.githubusercontent.com/Jiggins/081007c09d96afbc12bf/raw/9a6132f4c5459e332bf53fc897d76163e5585d75/git-setup.sh) | |
echo -n "Enter your name: " | |
read -e NAME | |
echo -n "Enter your Student Number: " | |
read -e STUDENT_NUMBER |
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
module Maybe where | |
import Prelude hiding (Maybe (..)) | |
-- Take a look at Hackage: Data.Maybe | |
-- https://hackage.haskell.org/package/base-4.8.1.0/docs/Data-Maybe.html | |
data Maybe a = Nothing | |
| Just a |
OlderNewer