Skip to content

Instantly share code, notes, and snippets.

Tracy Harms harms

  • Ohio
Block or report user

Report or block harms

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@harms
harms / test-isAceLowStraight
Created May 16, 2013
Example tests, applicable of 'isAceLowStraight'. Works in context of programs found at http://www.jsoftware.com/jwiki/TracyHarms/PokerHandsScoring
View test-isAceLowStraight
prep=: ranks @: makeHand
assert -. isAceLowStraight prep '6 D 4 H 3 C 2 S A C'
assert -. isAceLowStraight prep '6 H 5 D 4 H 3 C 2 S'
assert isAceLowStraight prep '5 D 4 H 3 C 2 S A C'
assert isAceLowStraight prep '5 D 4 D 3 D 2 D A D'
@harms
harms / digexamples.ijs
Created Sep 4, 2012
Three versions of 'dig', moving away from statement-based conditionals.
View digexamples.ijs
NB. These snippets are involved with a J implementation of RCRPG: http://rosettacode.org/wiki/Category:RCRPG
NB. That solution is still being written, so has not yet been posted to that website.
NB. The exercise of eliminating control-statements was largely inspired by the conversation on Twitter with @Huperniketes that included this comment: https://twitter.com/Huperniketes/status/240917975228637185
NB. NOTE: The version posted earlier, with tacit definitions of verbs such as fail_tool, did not work. The final portion has been corrected to fix this.
NB. Here's the original version of the verb 'dig' (omitting definitions of included names)
dig=: 3 : 0
if. PC_equipped includes 1 Sledge do.
@harms
harms / unshared.ijs
Created May 21, 2012
Example J solution to (Ruby) question asked by Bill Tozier
View unshared.ijs
unshared=: (-. , -.~) &. setForm
setForm=: convert :. revert
convert=: [: ; (<@(j. i.@#))/.~
revert=: /:~ @ {. @ |: @: +.
A=. 1 2 2 3 3 4 5
B=. 2 3 3 3 3 4 5 6
A unshared B
1 2 3 3 6
@harms
harms / POST_handler_sketch.ijs
Created Mar 8, 2012
J akin to a Scala Option example.
View POST_handler_sketch.ijs
NB. preparatory
OrFailureReport=: adverb : ' u ` asFailure @. fails '
UnlessFailed=: adverb : ' u ` ] @. fails '
NotingUnknownParsingError=: ::((makeFailure 'Unknown error in parsing attempt.')"_)
FAILMARK=: < s:'`_|_' NB. arbitrary
makeFailure=: [: < FAILMARK ; < :[:
fails=: [:+./ [:flatten (FAILMARK e. ]) L:1
NB. main
@harms
harms / gist:1624764
Created Jan 17, 2012
J for directionally filtering out rows or columns of a matrix.
View gist:1624764
'byRow byColumn'=: <"0 s:' Row Column' NB. these two names may be any two distinct values
nix=: 2 :' #~"(1+n=byRow) -.@ u"(1+n=byColumn) '
NB. examples of use:
(2={.) nix byColumn i. 3 5
0 1 3 4
5 6 8 9
10 11 13 14
@harms
harms / gist:1444658
Created Dec 7, 2011
Counting characters by kind.
View gist:1444658
whitespace=: 9 10 32 { a.
vowel =: ( , toupper) 'aeiou'
consonant =: vowel -.~ a.{~ , 97 65 +"0 _ i.26
other =: a. -. whitespace, vowel, consonant
kind=: whitespace; vowel; consonant; other
count=: ([: +/ ] e. >@[ )" _1 _
@harms
harms / PrimeFactorsTddJoke.ijs
Created Feb 14, 2011
An indulgence in sarcastic humor.
View PrimeFactorsTddJoke.ijs
NB. The Prime Factor Kata, in J
NB. -- an exercise in humor --
NB. Inspired by http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata
NB. RED
testPrimeFactors =: 3 : 0
assert ($0) -: primefactors 1 NB. add test of 1
)
NB. GREEN
You can’t perform that action at this time.