Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hyper operator

Name: Anonymous 2009-01-11 22:52

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))

hyper a n b = (hyper' n) a b


improvements to the above are welcome.

Name: Anonymous 2009-01-11 23:00

>>1

class Hyper

        public static void main(String args[])
        {
           System.out.println("ENTERPRISE QUALITY HYPER OPERATOR");
        }
}

Name: Anonymous 2009-01-12 0:40

hyper' :: (Integral a) => a -> (a -> a -> a)
hyper :: (Integral a) => a -> a -> a -> a

hyper' 0 = (+) . flip (^) 0
hyper' 1 = (+)
hyper' 2 = (*)
hyper' 3 = (^)
hyper' 4 = flip (flip (!!) . fromIntegral) . hyper4list
    where hyper4list a = 1 : zipWith (^) [a,a..] (hyper4list a)
hyper' n = flip (flip (!!) . fromIntegral) . hyperlist n
    where hyperlist n a = 1 : zipWith (hyper' (n - 1)) [a,a..] (hyperlist n a)

hyper a n b = hyper' n a b

Name: Anonymous 2009-01-12 5:15

hyper 1 a b = a + b
hyper n a b = foldr1 (hyper (n-1)) $ replicate b a

Name: Anonymous 2009-01-12 5:51

>>4
1. doesn't work for n=0.
2. arguments are in the wrong order.
3. slow as fuck.

Name: Anonymous 2009-01-12 7:36

>>5
But ... it's [i]SHORTER[/i]

Name: Anonymous 2009-01-12 7:37

HOW did I fuck up the BBCODE

Name: Anonymous 2009-01-12 17:29

>>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.

>>3
hyper' 0 = flip seq . (+) 1
hyper' 1 = (+)
hyper' 2 = (*)
hyper' 3 = flip (^)
hyper' 4 = ((foldr1 (^)) `dot` replicate) . fromIntegral
           where dot = (.).(.)
hyper' n = ((foldl1 (hyper' (n-1))) `dot` replicate) . fromIntegral
           where dot = (.).(.)

hyper a n b = hyper' n b a

Name: Anonymous 2009-01-12 17:54

ITT: losers

Name: Anonymous 2009-01-15 10:15

import List (genericIndex)

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)

hyper = genericIndex `dot` flip hyperList
    where dot = (.) . (.)

Name: Anonymous 2009-01-15 13:56

>>9
Back to /b/, please.

Name: Anonymous 2009-01-16 5:28

no one can do this in any language except haskell?
not even scheme? come on, this is the type of thing toy languages like that are made for!

Name: Anonymous 2009-01-16 5:35

>>12
Scheme is an useless toy language only good for its SICP appeal.

Name: Anonymous 2009-01-16 5:36

>>13
Nine out of ten adware authors disagree.

Name: Anonymous 2009-01-16 7:09


haxMyAnus :: (Anus a, Hax b) => a -> b -> a

sub hax {
    $item = @_[0];
    print "$item was haxed";
}

Name: Anonymous 2009-01-16 8:42

>>15
hyp(2,3,4)
OH SHI-

Name: Anonymous 2009-01-16 9:10

>>12
What did you expect from /hskl/?

Name: Anonymous 2009-01-22 10:51

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: Anonymous 2009-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).

Name: Anonymous 2009-01-22 13:10

ITT hyper

Name: Anonymous 2009-01-22 13:59

What does this have to do with HTML?

Name: Anonymous 2009-01-22 14:46

>>16
Peskell 6!?

Name: Anonymous 2009-01-23 4:16

USING: combinators.lib math.functions memoize ;

IN: hyper

MEMO: hyper ( b a n -- r ) {
  { [ 0 = ]                [ 2drop 1+ ] }
  { [ drop [ 2 = ] both? ] [ 3drop 4 ] }
  { [ 1 = ]                [ drop + ] }
  { [ drop 1 = ]           [ drop nip ] }
  { [ 2 = ]                [ drop * ] }
  { [ drop 0 = ]           [ 3drop 1 ] }
  { [ 2drop 0 = ]          [ 3drop 0 ] }
  { [ 3 = ]                [ drop swap ^ ] }
  { [ 4 = ]                [ drop <array> 1 [ 3 hyper ] reduce ] }
  { [ 4 > ]                [ >r <array> 1 r> 1- [ hyper ] curry reduce ] }
 } switch ;

Name: Anonymous 2009-01-23 10:55

,>,>,>
++[++[+-.,.<..,.<[+++++++++++++,+++++++++++++<<++++]--+,.[-]>>[-]>+[+]>,,-[-]>,
>>[+,]>>[,+]
>>[+,]>>[,+]
>>[+,]>>[,+]
>>[+,]>>[,+]
>>[+,]>>[,+]
>>[+,]>>[,+]
>>[+,]>>[,+]
>>[+,]>>[,+]
,.]>++++++[->-]-<<<<,.,,<.

Name: Anonymous 2009-02-06 5:00

{
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: Anonymous 2009-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: Anonymous 2009-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.
*/

import java.awt.geom.Arc2D.Float;
import java.util.Scanner;

public class CurrencyDollarConverter {

    /* 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) {
       
        /* variables */
       
        Double currencyExchangeRate;
        Double currencyAmount;
        Double dollarAmountUSA;
        Double dollarsForCustomer;
        Double exchangeFee;
        Integer twenties;
        Integer tens;
        Integer fives;
        Integer ones;
        Integer quarters;
        Integer dimes;
        Integer nickels;
        Integer pennies;
       
        /* inputs from the user */
       
        Scanner keyboard = new Scanner(System.in);
        System.out.println ("Please Enter First Name:\t");
        String firstName = keyboard.next();
        System.out.println ("Please Enter Last Name:\t");
        String lastName = keyboard.next();
        System.out.println ("Please Enter Currency Type:");
        String currencyType = keyboard.next();
        System.out.println ("Please Enter Currency Exchange Rate:");
        currencyExchangeRate = keyboard.nextDouble();
        System.out.println ("Please Enter Amount Of Currency:");
        currencyAmount = keyboard.nextDouble();
       
        /* math and computation */
               
        dollarAmountUSA = currencyAmount*currencyExchangeRate;
        exchangeFee = dollarAmountUSA*EXCHANGE_FEE;
        dollarsForCustomer = dollarAmountUSA - exchangeFee;
       
        /* computation for "change paid to customer" */
       
        int(dollarsForCustomer) = intDollarsForCustomer;
        twenties = dollarsForCustomer / 20;
        dollarsForCustomer = dollarsForCustomer % 20;
        tens = dollarsForCustomer / 10;
       
        quarters = dollarsForCustomer / 25;
        dollarsForCustomer = dollarsForCustomer % 25;
        dimes = dollarsForCustomer / 10;
        dollarsForCustomer = dollarsForCustomer % 10;
        nickels = dollarsForCustomer / 5;
        dollarsForCustomer = dollarsForCustomer % 5;
        pennies = dollarsForCustomer;
       
        /* outputs from the program */
       
        System.out.println ("Currency Transaction Summary: ");
        System.out.println ("Customer: " +lastName + ", " + firstName);
        System.out.println ("Currency Amount: " + currencyAmount + "(" + currencyType + ")");
        System.out.println ("Currency Exchange Rate: " + currencyExchangeRate + " US Dollar per " + currencyType);
        System.out.println ("US Dollar Amount: " + dollarAmountUSA);
        System.out.println ("Exchange Fee (1.2%: " + exchangeFee);
        System.out.println ("Total US Dollars: " + dollarsForCustomer);
        System.out.println ();
            System.out.println ("Amount paid to customer: " +dollarsForCustomer);
            System.out.println ("Exact change paid to customer:");
                System.out.println (twenties + "Twenty Dollar Bills");
                System.out.println (tens + "Ten Dollar Bills");
                System.out.println (fives + "Five Dollar Bills");
                System.out.println (ones + "One Dollar Bills");
                System.out.println (quarters + "Quarters");
                System.out.println (dimes + "Dimes");
                System.out.println (nickels + "Nickels");
                System.out.println (pennies + "Pennies");
    }       
   

}

Name: Anonymous 2009-02-06 18:29

sorry i forgot to post this in a new thread.

Name: Anonymous 2009-02-06 18:29

jänis

Name: Anonymous 2009-02-06 23:00

import java.awt.geom.Arc2D.Float;
wat

Name: Anonymous 2009-02-07 2:33


technotechnotechno
techno

Name: Anonymous 2009-02-07 3:17

>>28
This is some of the ugliest code I have ever seen.

Name: Anonymous 2009-02-07 4:19

>>33
Happy?

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];
        }
    }
}

Name: Anonymous 2009-02-07 4:36

>>28-34
please don't shit on this thread. this thread is about programming and maths, not your stupid /pr/ shit.

Name: Anonymous 2009-02-07 4:39

>>35
please don't shit out your anus while i hax it

Name: Anonymous 2009-02-07 11:03

>>35
maths
British person detected

Name: Anonymous 2010-01-22 4:30

>>26
Where's the
*
"GRUNNUR"
;
part?

Name: Anonymous 2010-01-22 4:48

>>38
It doesn't have a link target either, so clearly this isn't meant to be a full program.

Name: Cheap wholesale clothing 2010-06-29 9:25

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

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List