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 2010-06-29 12:29

>>37
Hahaha Britain, what a load of chumps am I correct?

Name: Anonymous 2010-06-29 13:28

Enjoy your AIDS AND FAIL, /prog/

Name: Anonymous 2010-10-14 22:47

ANuws OPERTAOR

Name: Anonymous 2010-11-25 5:31

Name: Anonymous 2012-05-18 15:22

>>43
vip wquality

Name: Anonymous 2012-05-18 15:58

>>37
Only-black-people-can-say-nigger Ameritard detected.

Name: Anonymous 2012-05-18 20:35


let rec hyper n a b = match (n, a, b) with
                        | (0,_,_) -> b + 1
                        | (1,_,0) -> a
                        | (2,_,0) -> 0
                        | (n,_,0) when n >= 3 -> 1
                        | _ -> hyper (n-1) a (hyper n a (b-1))

love you, f# / ocaml.net

Name: Anonymous 2012-05-18 20:51

>>48
update - tail recursion ftw

let rec _hyper n a b f = match (n, a, b) with
                        | (0,_,_) -> f (b + 1)
                        | (1,_,0) -> f a
                        | (2,_,0) -> f 0
                        | (n,_,0) when n >= 3 -> f 1
                        | _ -> _hyper n a (b-1) (fun b -> _hyper (n-1) a b f)
let hyper n a b = _hyper n a b (fun ans -> ans)

Name: Anonymous 2012-05-18 22:52

hyper _ 0 b = b + 1
hyper 2 _ 2 = 4
hyper a 1 b = a + b
hyper a _ 1 = a
hyper a 2 b = a * b
hyper _ _ 0 = 1
hyper 0 _ _ = 0
hyper 1 _ _ = 1
hyper a 3 b = a ^ b
hyper a 4 b = foldl1' (flip (^)) $ genericReplicate b a
hyper a n b = foldl1' (flip (flip hyper (n - 1))) $ genericReplicate b a

Name: Anonymous 2012-05-18 23:30

h(n, a, b) { return (n && b) ? h(n - 1, a, h(n, a, b - 1)) : (n < 3) * (int[]){b + 1, a, 0}[n]; }

Name: Anonymous 2012-05-19 8:26

>>50
That's just so elegant. This is why I love Haskell and ML.

Name: Anonymous 2012-05-19 8:44

>>52
Too bad they'll never replace C++ and Java.

Name: Anonymous 2012-05-19 9:00

>>52
haskellerDayTimeJob burger = flip burger

Name: Anonymous 2012-05-19 9:05

>>54
implying
babby.jpg

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-05-19 9:47

>>52
Look at the generated code and you'll probably change your mind.

Name: Anonymous 2012-05-19 9:59

>2012
>not enjoying the hyper operator
>quote
http://www.youtube.com/watch?v=7Twnmhe948A

Name: Anonymous 2012-05-19 10:26

Name: Anonymous 2012-05-19 15:35

>>56
Most CPU architectures aren't designed for that kind of language. It would be straightforward on an FPGA or in VAX or S/370 microcode. Microcode has been written to emulate instruction sets designed for languages like APL (dynamic types) and Prolog (pattern matching and backtracking) more efficiently than the main instruction set. After all, instruction decoding is a form of pattern matching.
http://bitsavers.org/pdf/ibm/apl/ZZ20-6428_The_APL_Assist_Feb75.pdf
http://www.eecs.berkeley.edu/Pubs/TechRpts/1988/CSD-88-399.pdf

Name: Anonymous 2012-05-19 19:27

use feature qw(switch);
use List::Util 'reduce';

sub hyper($$$)
{ given (join ' ', @_)
  { when (/ 0 (\d+)$/)           { $1 + 1 }
    when (/^2 \d+ 2$/)           { 4 }
    when (/^(\d+) 1 (\d+)$/)     { $1 + $2 }
    when (/^(\d+) \d+ 1$/)       { $1 }
    when (/^(\d+) 2 (\d+)$/)     { $1 * $2 }
    when (/ 0$/)                 { 1 }
    when (/^0 /)                 { 0 }
    when (/^1 /)                 { 1 }
    when (/^(\d+) 3 (\d+)$/)     { $1 ** $2 }
    when (/^(\d+) 4 (\d+)$/)     { reduce { $b ** $a } ($1) x $2 }
    when (/^(\d+) (\d+) (\d+)$/) { reduce { hyper($b, $2 - 1, $a) } ($1) x $3 }}}

Name: Anonymous 2012-05-19 20:46

my Int sub hyper(Int $a, Int $n, Int $b)
{ return $b + 1        if !$n;
  return 4             if [==] $a, $b, 2;
  return $a + $b       if $n == 0;
  return $a            if $b == 1;
  return $a * $b       if $n == 2;
  return 1             if !$b;
  return 0             if !$a;
  return 1             if $a == 1;
  return $a ** $b      if $n == 3;
  return [**] $a xx $b if $n == 4;
  return reduce sub ($x, $y) { hyper($y, $n - 1, $x) }, $a xx $b; }

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-05-20 9:11

>>58
This is the type of thinking that makes software get more and more inefficient.

Clock speeds have increased over 3 orders of magnitude. Productivity has not. And programmers thinking their time is more valuable than everyone else's are producing applications that, for their own savings of maybe a few hours, are wasting many times that on their combined userbase, every time those users use them.

Name: VIPPER 2012-05-20 9:24

>>62
There is no reason to be overly obsessive with efficiency these days, unless it is designed for specialized usage, like embedded, realtime or supercomputation.

Too many programmers talk about speed and stuff when i doesnt even matter much in the end instead of effectively improving software.

But what is even worse is that programmers stash useless graphical gimmicks that have no use whatever other than looking pretty and end up wasting tons of resources.

Name: Anonymous 2012-05-20 9:53

>>62
When I write software and take into account user efficiency, I usually only refactor the parts that feel like it takes longer than it should. Usually, this is a matter of refactoring the way the system reacts to user input. Users normally don't care that something takes a long time if they retain the ability to control the system. This means it should not take more than fractions of a second to respond to input events but the actual processing of the data can take place over many seconds. This also means that the system should give satisfactory feedback whenever processing data takes longer than a couple of seconds.

By structuring the UI in this manner, you can deliver systems that can actually cost a lot of time to process but also feel like it's not wasting time and energy from the users' point of view.

Name: Anonymous 2012-05-20 15:47

This also means that the system should give satisfactory feedback whenever processing data takes longer than a couple of seconds.
If processing data is going to take longer than it usually takes to respond to input, you should provide feedback immediately, no matter how long you expect it to take. The idea that "a couple of seconds" without any indication that anything worthwhile is happening is an acceptable delay is the reason why people like >>62 exist.

Name: Anonymous 2012-05-20 15:55

>>61
is there some way to improve that last line with one of those reduction operators?

Name: Anonymous 2012-05-20 17:54

>>66
nice dubz bro

Name: Anonymous 2012-05-21 16:07

All play and no work makes Jack a wise man.

Name: bampu pantsu 2012-05-29 4:07

bampu pantsu

Name: Anonymous 2012-06-17 19:39

All play and no work makes Jack a wizard at 30

Name: Anonymous 2012-06-19 11:47

䡔饴蘰需᎘ᜄᥲ瘢䥑鎂醅萶鉅ءጁ䤐䅂ᠠ晥䌩危進䜕㜷Ճ畓☸♂㞁၆蠁∤ᐓ剷瘉ᦀ瀹ႃ⤕啸䌧‡ї摃ⅵᖂԢ愥蜐饡瘕ᕩ鍦椙䕐甓妁袃❷逹ᅀ顰摱⑔噔挆逸葹䈵䉳ㅑ錷㡈㍈瘩奩脵䘐倂猧❗颈昔ɶ䐴ᒑ耘椦㥖㐁✔䀒鍈ᘗᄣ荥膁鞅”吓袓皗老ࡦ衙⠂ᔩ䥉䌣䕳ㄑ⅓銉扤ဩ顧つ䞙虐牴䖗硄ᑰ萠䥅膔ᕢ硵睤㉇䄸㠣夶敖抉祅饢摡̑⁥犖ᒙ嘆ɖ䠂慇嘩甆ㆇ圱蝙呐咑咙啖࠘䘷㉷ㅄ䄂䆗࢙倈偦㝃朶㞈餅舨钘☸猱墈夓腷䍒蜐ᔢ襂腂У⅐偠茦 塡隘㢑夀ޑ䔐蕣剨挆ж֕霱㉲㤗瑑顃♲̀ሔ镲荒ᘱ呰桩ᝆ吨ᆈ┅␧畹阠夃ᆐ斆煱㑦撘⎘邖ㄓ聲匢䅹敐熂腣鑸ڀ逰頨垄刢㈷Х͸閔㤥桗喆鑆㤨䞅桉慣՘搀腐ܲ醁ቇኖ䠀犃硸枂⎈䄳ጉ䄴ك∆逷ⅶ㔸奖墕慄⠑堈睩摢ሠ陘怈ƅख़@ॕ理ፅ蜃耲璙ܴ慆䍆錖⁰⢇ᙄŐㆁ䦔Ↄ匶

Name: Anonymous 2012-06-19 12:09

效蔳蕠☘蘈㎔᝹爤唳㡲╇坤㖐ဵ鞄猈䡘腹㦅ԙᕅ眰䘶♗ህĆ䈉塴妉葅鍸ᅈ㜗᠂怀癅ࠥ㜲䙨ঘ⥵阵䌨鉠v肂㉡䈷螉—䖑䄵聅̉䠀衢䅄㠉͗ᎄ墒ᘹ邃錐扵吓㌆䘧䔒舑楓႔䤒攐ч茦玒夘ʃ酉䀹倥唕摔颇⑃舆Ԩ噣ኗ焩䔑㌑玈ဖ㑹݈䅣䈲茠❡ᜀب锹倹ᅒ鞀㚅䍸鄃蔇薒莂ޑ剆褣ՠ䎂敥瑲琂舦癩ᜉ晤斈䠱䑄怀ᄘ〧脱怉ㅈ判3㕰⥠Ɓ͆搃⌦眰蚘㈙愒妔颀ㆁ䐆钙ᒇ䑇ᤈ硳ᒑܠ䔷萘め╕聴爣虤स镤ₔ鉐ᅂ၀䘗ᡘ顑䔆┸膂褲奤願荈⊆偑喂餱䡐蝇朶鑱倗㉷舒腂兓剦瑅ႃX顸䐓眤蜇眲厘䝖碓艴ጱ葉㠘顖璖┹䅒Ƀၰp陶儀畨阹⤸ᤲ蒑灄࢈睵挵蠶覇牣栰猢戗戀ናㄖ㌀ȶ悅㔩䘩ܤ⁵煙び猷≑獠ㅧ癡ԙ䐱㝹ޒ呶ॵ␉㥶➐㈑琑䊄朶逸Sፄ瞆✒ᎄ蜗䙔顆慀憄ሂ怆䘂蔶㜐皘镹萑␀鐤偅䀔搧ᅵ捶陵朙餈鉘ܘ礣锄䎉畈㉳

Name: Anonymous 2012-06-19 14:50

C++ is a good language. It is not a perfect language because it inherits from C. C is a flawed language where many things are left undefined. C is an ancient artifact that serves no purpose outside of the domain of kernel design. Because of the improvements made upon C to form C++, beginning programmers and veteran programmers alike may be led astray, thinking that modern C usage is a good idea. It is a mistake to believe the success of C++ justifies the continued use and popularity of C. Just because C++ is successful does not mean the language it has inherited from is of high quality.

Name: Anonymous 2012-06-20 12:35

It doesn't make any mathematical sense.

Name: Anonymous 2013-09-01 23:53

>>13
Don't talk shit about Scheme the moon rabbit.

>>40
Hi there, you can't post anymore ( ≖‿≖)

Name: Cheap wholesale clothing 2013-09-01 23:56

>>75
;_;

Name: Anonymous 2013-09-02 0:02

>>76
where are my loli sisters man!!!

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