http://en.wikipedia.org/wiki/Hyper_operator integralElem :: (Integral b) => [a] -> b -> a
hyper' :: (Integral a) => a -> (a -> a -> a)
hyper :: (Integral a) => a -> a -> a -> a
integralElem a b = a !! fromIntegral b
hyper' 0 = (+) . flip (^) 0
hyper' 1 = (+)
hyper' 2 = (*)
hyper' 3 = (^)
hyper' 4 = integralElem . (hyper4list)
where hyper4list a = 1 : (zipWith (^) [a,a..] (hyper4list a))
hyper' n = integralElem . (hyperlist n)
where hyperlist n a = 1 : (zipWith (hyper' (n-1)) [a,a..] (hyperlist n a))
>>4 Couldn't match expected type `Int' against inferred type `a'
`a' is a rigid type variable bound by
the type signature for `hyper' at hyper.hs:1:19
In the first argument of `replicate', namely `b'
In the second argument of `($)', namely `replicate b a'
In the expression: foldr1 (hyper (n - 1)) $ replicate b a hyper _ 0 b = b + 1
hyper a 1 b = a + b
hyper a n b = foldr1 (hyper (n - 1)) $ replicate (fromIntegral b) a
it's still slow as fuck, though, because it doesn't use (*) and (^) for n==2 and n==3.
hyperList 0 _ = [1..]
hyperList 1 a = map ((+) a) [0..]
hyperList 2 a = map ((*) a) [0..]
hyperList 3 a = map ((^) a) [0..]
hyperList 4 a = 1 : zipWith (^) (repeat a) (hyperList 4 a)
hyperList n a = 1 : zipWith (flip hyper (n - 1)) (repeat a) (hyperList n a)
Object.prototype.replicate = function(n){
var a = new Array(n);
for(var i = 0; i < n; ++i) a[i] = this;
return a;
}
function hyp(a,n,b){
if(n > 0 && a == 2 && b == 2) return 4;
if(n > 1 && !a && b) return 0;
if(n > 2 && a == 1) return 1;
switch(n){
case 0: return b + 1;
case 1: return a + b;
case 2: return a * b;
case 3: return Math.pow(a,b);
case 4: return a.replicate(b).reduce(function(x, y) Math.pow(y, x), 1);
case 5: return a.replicate(b).reduce(function(x, y) hyp(b, n - 1, a), 1);
default: return false;
}
}
Name:
Anonymous2009-01-22 11:18
hyper(_, 0, B, R) :- R is B + 1.
hyper(2, _, 2, R) :- R is 4.
hyper(A, 1, B, R) :- R is A + B.
hyper(A, _, 1, R) :- R is A.
hyper(A, 2, B, R) :- R is A * B.
hyper(_, _, 0, R) :- R is 1.
hyper(0, _, _, R) :- R is 0.
hyper(1, _, _, R) :- R is 1.
hyper(A, N, B, R) :- A > 1, N > 2, B > 1, B1 is B - 1, N1 is N - 1,
hyper(A, N, B1, Temp), hyper(A, N1, Temp, R).
{
hyper ->
stef(;a,n,b)
staðvær r
stofn
ef n=0 þá
b+1,
annarsef a=2 & b=2 þá
4,
annarsef n=1 þá
a+b,
annarsef b=1 þá
a,
annarsef n=2 þá
a*b,
annarsef b=0 þá
1,
annarsef a=0 þá
0,
annarsef a=1 þá
1,
annars
fyrir( r:=a ; b>1 ; b:=b-1 ) lykkja
r := hyper(;a,n-1,r),
lykkjulok,
r,
eflok
stofnlok
}
Name:
Anonymous2009-02-06 5:24
using System;
using System.Collections.Generic;
using System.Numerics;
namespace Ackermann
{
class Ackermann
{
public static BigInteger Hyper(BigInteger a, BigInteger n, BigInteger b)
{
if (n == new BigInteger(1)) return a + b;
if (n == new BigInteger(2)) return a * b;
if (b == new BigInteger(0)) return new BigInteger(1);
if (n == new BigInteger(0)) return b + new BigInteger(1);
if (a == new BigInteger(0)) return new BigInteger(0);
else return Hyper(a, n - new BigInteger(1), Hyper(a, n, b - new BigInteger(1)));
}
public static BigInteger Ack(BigInteger m, BigInteger n)
{
if (m == new BigInteger(0)) return n + new BigInteger(1);
if (m == new BigInteger(1)) return n + new BigInteger(2);
if (m == new BigInteger(2)) return new BigInteger(2) * n + new BigInteger(3);
else return Hyper(new BigInteger(2), m, n + new BigInteger(3)) - new BigInteger(3);
}
}
}
Name:
Anonymous2009-02-06 18:28
I need help converting from a double to an int or at least i need the values in amount paid to customer to be in the form xx.xx instead of xx.xxxxxxxxxxxxx(etc.)
/*
* CurrencyDollarConverter.java
* Author: MEMEMEMEMEMEMEMEME
* Last edited: 02/06/2009
*
* Purpose: CurrencyDollarConverter.java will display
* the details of a customer’s currency exchange transaction,
* as well as the amount of US Dollars and exact change paid
* to the customer after the currency exchange transaction has been made.
*
* Statement of Academic Honesty:
*
* The following code represents my own work. I have neither
* received nor given inappropriate assistance. I have not copied
* or modified code from any source other than the course webpage
* or the course textbook. I recognize that any unauthorized
* assistance or plagiarism will be handled in accordance with
* the University of Georgia's Academic Honesty Policy and the
* policies of this course.
*/
/* I would prefer calling the variable EXCHANGE_RATE as the 1.2% is a fixed rate
* but the .pdf file says to label it as EXCHANGE_FEE. This would also prevent
* confusion between the EXCHANGE_FEE and the later variable exchangeFee
*/
public static final double EXCHANGE_FEE = 0.012;
public static void main(String[] args) {
import java.util.Scanner;
import java.text.DecimalFormat;
public class CurrencyDollarConverter {
//I would prefer leaving this variable as EXCHANGE_FEE because it shows the proportion of a transaction which is taken as fees and has nothing to do with the exchange rate
private static final double EXCHANGE_FEE = 0.012;
private static final String[] lines = {"Please enter your first name","Please enter your last name","Please enter a currency type","Please enter currency exchange rate","Please enter amount of currency"};
private static final int[] notes = {2000,1000,500,25,10,5,1}; //value of denominations in cents
private static final String[] names = {"Twenty","Ten","Five","Quarters","Dimes","Nickels","Pennies"};
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
DecimalFormat nF = new DecimalFormat(".00");
String[] inputs = new String[lines.length];
for(int i=0; i<lines.length; i++) {
System.out.print(lines[i]+": ");
inputs[i] = scan.nextLine();
}
double amount = Double.parseDouble(inputs[4]);
double rate = Double.parseDouble(inputs[3]);
double USAmount = amount*rate;
double fee = USAmount*EXCHANGE_FEE;
double endAmount = USAmount-fee;
System.out.println("Currency Transaction Summary:");
System.out.println("Customer: "+inputs[1]+", "+inputs[0]);
System.out.println("Currency Amount: "+nF.format(amount)+" ("+inputs[2]+")");
System.out.println("Currency Exchange Rate: "+rate+" US dollars per "+inputs[2]);
System.out.println("US dollar amount: $"+nF.format(amount*rate));
System.out.println("Exchange fee ("+EXCHANGE_FEE*100+"%: $"+nF.format(fee)+")");
System.out.println("Total US dollars: $"+nF.format(endAmount)+"\n");
int dedAmount = (int)(endAmount*100); //convert to cents
for(int i=0; i<notes.length; i++) {
int tempAmt = dedAmount/notes[i];
if(tempAmt==0) continue;
String pad = notes[i]>100?" Dollar Bills":"";
System.out.println(tempAmt+" "+names[i]+pad);
dedAmount = dedAmount % notes[i];
}
}
}
wholesale men's clothing a little late on the chain tee print but it’s kinda nice either way. Ecko might have even already did it? Scifen wholesale women's clothing is picking up on demand for sure. Stores from GoGenx to Macys Department Stores back to Dr Jays cheap wholesale clothing store on-line is carrying them. Check the update on GoGenx, frehs! http://www.freewholesale.net