text:
What do you get when you multiply 6 by 9? (42)
I love math. But I can't find a single calculator that can multiply correctly. They seem to get everything right except 6*9 (It's the question to life, the universe, and everything! How could they get that wrong?!). So I want you all to write a function for me that can multiply 2 numbers correctly (and 6*9 equals 42 instead of 54. 9*6 equals 54 still).
Oh, and I'm going to have to build the source in Minecraft so... fewest bytes win!
Recap

Take 2 numbers as input (type doesn't matter, but only 2 items will be passed, and order must be consistent. So streams, and arrays are ok as long as they preserve the order they where passed in. I.e., a map won't work because it doesn't preserve the order)
Output multiple of both numbers except if they are 6 and 9, then output 42 (order matters!)

PS. I never was really good with counting, so I think only integers from 0 to 99 are real numbers (type used doesn't matter)

Fewest bytes per language wins!

Leaderboard:

var QUESTION_ID=124242,OVERRIDE_USER=61474;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+r.match(SCORE_REG)[0],language:r.match(LANG_REG)[0].replace(/<\/?[^>]*>/g,"").trim(),link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/\d+((?=$)|(?= Bytes))/i,OVERRIDE_REG=/^Override\s*header:\s*/i;LANG_REG=/^[^,(\n\r]+/i
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/Sites/codegolf/all.css?v=617d0685f6f3">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

May the input be a list of numbers?

@MartinEnder Added rules to address that

@JonathanAllan Yes, added rules for that.

Coincidentally the question id has 42 twice in it.

if only integers up to 99 are real numbers, then e.g. 9 * 11 is a valid prompt but 10 * 10 is not, right?

@thedarkwanderer. 0 to 99 is the valid input, 0 to 9999 is the valid output

@EriktheOutgolfer …and the 12 stands for what to subtract if input is 6 and 9.

@Adám Just the absolutely perfect question id for this question.

@EriktheOutgolfer Even if you read the ID backwards.

42 is 54 in base 13.  Note that 6 and 9 are valid in base 13  One answer has that, surprised not more

When I saw the title, I expected it to be about finding bases where the equation is true but it turns out that already exists.

fixed the score

Mathematica, 15 bytes
Byte count assumes Windows ANSI encoding (CP-1252).
6±9=42
±n__:=1n

Defines a binary operator ± which solves the problem. We simply define 6±9=42 as a special case which takes precedence and then add a fallback definition which makes ± equal to multiplication. The latter uses a fairly interesting golfing trick. The reason this works is actually quite elaborate and we need to look into sequences. A sequence is similar to what's known as a splat in other languages. It's basically a "list" without any wrapper around it. E.g. f[1, Sequence[2, 3, 4], 5] is really just f[1, 2, 3, 4, 5]. The other important concept is that all operators are just syntactic sugar. In particular, ± can be used as a unary or binary operator and represents the head PlusMinus. So ±x is PlusMinus[x] and a±b is PlusMinus[a,b].
Now we have the definition ±n__. This is shorthand for defining PlusMinus[n__]. But n__ represents an arbitrary sequence of arguments. So this actually adds a definition for binary (and n-ary) usagess of PlusMinus as well. The value of this definition is 1n. How does this multiply the arguments? Well, 1n uses Mathematica's implicit multiplication by juxtaposition so it's equivalent to 1*n. But * is also just shorthand for Times[1,n]. Now, n is sequence of arguments. So if we invoke a±b then this will actually become Times[1,a,b]. And that's just a*b.
I think it's quite neat how this syntax abuse lets us define a binary operator using unary syntax. We could now even do PlusMinus[2,3,4] to compute 24 (which can also be written as ±##&[2,3,4] or 2±Sequence[3,4] but it's just getting crazy at that point).

I particularly like how this is basically a patch for my 'calculator' :3 For fun, does this work for * too? :3

@Tezra well, * is a built-in operator, so you'd have to Unprotect it to add further definitions, but Unprotect[Times];6*9=42 should work (can't test right now though).

Doing this to the * operator is just so evil.... I love it! >:3

+1 for this crazy but intersting abuse of sequence and times. It took me a minute or two to fully understand this whole code. Very cool.

How can I upvote when there are exactly 42 others?!? Here's my "future +1" to be awarded after someone else breaks it! :-)

@Tezra thanks for the checkmark, but this is not the shortest answer so it shouldn't be accepted. If you don't want to pin the shortest answer to the top for whatever reason it is better not to accept an answer at all.

@MartinEnder Aww; But it's the shortest Mathematica one, and my favorite so far. :3

The trick with ±n__ getting parsed as PlusMinus[n__] and accepting infix notation further on is my favourite Mathematica hack of all time. I don't have much but I think there'll be enough for a little bounty!

@TheVee thank you, that's very kind. :)

Haskell, 14 bytes
6&9=42
a&b=a*b

Try it online!

C, 32 31 29 28 bytes
-2 thanks to Digital Trauma
-1 thanks to musicman523
#define f(a,b)a^6|b^9?a*b:42

Pretty simple. Declares a macro function f that takes two arguments, a and b.
 If a is 6 and b is 9, return 42. Otherwise return a x b.
Try it online!

Use ^ instead of == and adjust the logic a bit: #define f(a,b)a^6||b^9?a*b:42 - saves 2 bytes.

I think you can use | instead of || to save another byte, since it still has lower precedence than ^

You should update your shortC version to take these changes as well

JavaScript (ES6), 20 bytes
x=>y=>x-6|y-9?x*y:42

Explanation:
Iff x==6 and y==9, x-6|y-9 will be 0 (falsy), and 42 will be the result.
Snippet:

f=

x=>y=>x-6|y-9?x*y:42

console.log(f(6)(9));
console.log(f(9)(6));

Very nicely done; wish I'd thought of it. +1

Python 2, 30 29 bytes
Thanks to Jonathan Allan for saving a byte!
lambda x,y:x*[y,7][6==x==y-3]

Try it online!

Save a byte using the fact that 6*7 is 42: lambda x,y:x*[y,7][6==x==y-3]

@JonathanAllan Ohh, that's neat! Thanks! :)

This solution also works in Python 3

Exactly what I got! Can't seem to find any way to golf it further.

05AB1E, 15 11 9 bytes
-4 bytes thanks to @Emigna
-2 bytes thanks to @Adnan
P¹69SQi42

Try it online!
How it works
P          # multiply input
 ¹         # push first number
  69       # the number 69
    S      # split per character
     Q     # equality for both inputs
       i42 # if so, print 42
           # otherwise print product

You could save 4 bytes with ‚D96SQi42ëP

@Emigna huh... Why the , at the beginning?

Pairing the 2 inputs to compare only once as a list.

I suppose 6Qs9Q* would have worked as well for the same byte count.

Changing the input format saves 2 bytes: P¹69SQi42

@Adnan: Didn't see the rules changed. Thanks!

Java (OpenJDK 8), 24 22 bytes
-2 bytes thanks to @OlivierGrégoire
a->b->a==6&b==9?42:a*b

Try it online!

Welcome to PPCG! I don't know much about Java, but could you remove the System.out.println() call and just let the function return the result?

True, I thought I had to explicitly print the result. Thanks for saving me 17 bytes!

as suggested here, using ^ will save you several bytes

@LưuVĩnhPhúc not in Java, because I'd have to write (a^6|b^9)==0 since there is no implicit "different than 0" comparison. The resulting code snippet would be 27 bytes long. Anyways, thanks for the suggestion, and please tell me if I got your tip wrong.

@CoffeeandClonazepam I'm not great at java, but doesn't every number other than 0 evaluate to true?  We don't require an explicit cast to boolean, as long as the return value can be casted to the correct boolean output.

@Riker nope, it does not work like that in java. E.g. the snippet int a = 5; if (a) do_some_stuff(); else do_other_stuff(); gives a Type mismatch: cannot convert from int to boolean compilation error. They must be made explicitly with boolean values; refer to SO and ORACLE.

@Riker Try it online! Main.java:4: error: incompatible types: int cannot be converted to boolean

@CoffeeandClonazepam ah, okay.

You can use currying to spare one byte, and you can get rid of the semicolon as it's not part of the lambda to spare another byte: a->b->a==6&b==9?42:a*b.

@OlivierGrégoire Good point, thank you!

Just a note why the 0 is not false. Java is type safe so 0 is an integer not a boolean and unsafe typecasting is not allowed so you can't use falsy values

@MartinBarker, thanks for the explanation!

@MartinBarker to show a concrete example, if (0) { } else { } won't compile in Java. That's why 0 isn't a valid falsy type.

Ruby, 24 bytes
->a,b{a==6&&b==9?42:a*b}

a^6|b^9<1 might work as boolean. Hard to test on my smartphone.

@EricDuminil Unfortunately that expression is parsed as (((a^6)|b)^9), i.e. a.^(6).|(b).^(9), so it won't work correctly. a-6|b-9==0 would work, but that's no shorter.

@Ventero: I didn't think about that. Thanks. a,b==6,9 would be nice, but it also doesn't work.

a<<b==69 doesn’t quite work either :( Try it online!

Brain-Flak, 158 154 148 140 138 126 bytes
(({}<>)(((([()()()]<>)){})<({}{}({}))>{(()()()){}(<{}>)}{}))([()]{()(<{}>)}{})(({<{}>{}((<>))}{}){}<{}>{<({}[()])><>({})<>}{})

Try it online!
Explanation
This code is pretty simple.  We make copies of the top two items on the stack, we subtract 6 from one and 9 from the other.  We then take the not of the two values.  We and those values, multiply the result by 12.  Multiply the inputs and subtract the two results.

You might want to capitalize not and and (or backtick them), reading your description rather tripped me up.

MATL, 11 bytes
[BE]=?42}Gp

Input is an array with the two numbers.
Try it online!
Explanation
[BE]    % Push array [6, 9]
=       % Implicit input: array of two numbers. Compare with [6, 9] element-wise
?       % If the two entries are true
  42    %   Push 42
}       % Else
  G     %   Push input
  p     %   Product of array
        % Implicit end. Implicit display

Jelly, 8 7 bytes
Vf96SạP

Input is as an array of two integers: first the right operand, then the left one.
Try it online!
How it works
Vf96SạP  Main link. Argument: [b, a]

V        Cast [b, a] to string, then eval the resulting string.
         For [b, a] = [9, 6], this yields 96.
 f96     Filter with 96, yielding [96] if V returned 96, [] otherwise.
    S    Take the sum, yielding either 96 or 0.
      P  Compute the product of [b, a], yielding ba = ab.
     ạ   Compute the absolute difference of the results to both sides.
         When the sum is 0, this simply yields the product.
         However, when [b, a] = [9, 6], this yields 96 - 54 = 42.

This has like -1 degree of freedom. How do these coincidences even occur to you?

Factorio, 661 bytes, 6 combinators with 9 connections
There is one constant combinator set to output A and B. Change these to set the input.
Blueprint string (0.15.18):
0eNrNVm2O2jAQvcv8rEKFvSHLRuqPtrfYCkUhGWAkYkfOGDVCOUBv0bP1JLWTLQuB3U0QbfcPYvzxZt68eYr3sNxaLA0phngPlGlVQfxtDxWtVbr1a1yXCDEQYwEBqLTwUY4Z5WgmmS6WpFLWBpoASOX4HWLRBG8C+EScKr6MIJtFAKiYmLCrpw3qRNliicaleK2SAEpduata+fQObiI+zgKo/R+XIyeDWbcrA18IG71NlrhJd+RuuytPmInby1ucyq+uyFScnPHakWHrVg4VdScmnz2fPzQhjnxQlKlpS4zhk7ugLZd2BCTu0NS8IbXusMvalWgVJyuji4SUA4OYjcWmS606nm31wv8YzI+7SS66axbusHxh1zeITGaJ21C4w41XtyeHHCXH9D+o8eVUjYd3qoY47bc86rWPo158/yze2iCqPtxsmHx3r9ry3E6ylU9cTUv0aITDygwPZaaGeFMgUzbM99NBg/aMegPnV+gxRg6oLtFNZFsjfLhiJB+huZn1B87O7Crr/0Pnfz11vug5/9ePn+/E+2Hf++4beNHV8uzgRWWica6ejnDKiraM5oWXwhtC2CcVDo+FxfAWDfwc3Y9jLv4288cj5qG8IXU3Ie2zKj56xgXgZrNqOURhKGfR/GE6nzfNb7OMaxo=

The output is signal Z and is to be taken from the top and bottom deciders.

waaa... first time i ever see a factorio answer in ppcg xD

Not golfy enough.

Factorio, 581 bytes, 3 combinators with 4 connections
Blueprint string (0.16.36):
0eNqllNtu4jAQht9lLldmldNCFWkvto/RCkUhGWAkYkfOGDVCefeOnV1Km7ACemPJ9vibf04+webgsLWkGfITUGV0B/nrCTra6fLgz7hvEXIgxgYU6LLxO2/HpeZFZZoN6ZKNhUEB6RrfII+HtQLUTEw44sKmL7RrNmjF4AyqsaIa7SVHQWs6eWq0dy+46OcvBT3ki1hc1GSxGi8T5XWwNYdig/vySPJYXvxFFnJXB0znT7dkOy4mYR3JspOTs6DRYoFHtD3vSe98XP/CFZ9xtsqe0mW29KdNW9qgOYffgjCOW3eHk+eR3fai1WkuttY0BWlhQM7W4TC61mPAIYzYLxbry6yS7FKxJFs54rANFdhZRP3VMBnWQk08ZvZ+ChpExqSCyX9bYVLCRfxRwbmabenAaK+03rX0/RnT5z7VJbroQnUH7HkGlq7OsDFtc8WYzWJ8WxbTs4rSEu8bZKpuGoXopkn4gH5vGEKiO/SMO5vbtCgDEjTCjwcm5AWGO4ZgknX16Tq7OhRfHiZXypU91PTRd6ZYdIjo8PnmF3+1AvmfuuBq+bRKYmnWKM2G4R1hAPnz

The bottom left constant combinator should be set to output A and B as input. The output is signal Z from the bottom right arithmetic combinator.

Top left: 2147483640 A, 2147483637 B
Top right: If everything = 2147483646 output B, input count
Bottom left: (input) A, (input) B
Bottom right: A * B -> Z

R, 33 bytes
function(a,b)`if`(a-6|b-9,a*b,42)

Returns a function.
Try it online!

You can save 3 bytes with a*b-12*!(a-6|b-9).

GW-BASIC, 55 bytes
1INPUT A:INPUT B
2IF A=6THEN IF B=9THEN ?"42":END
3?A*B

Output:

The first machine at pcjs has IBM BASIC, which is practically the same thing. To test this, head over there, hit Run on the machine, Press Enter-Enter and type BASICA to get into BASIC mode. Then enter the source code (it will automatically prettyprint for you), type RUN, input two integers, and done!

Are you sure the bytecount is correct? GW-BASIC uses an encoding in which some words, like INPUT, are encoded in fewer bytes than the characters that make them up would suggest. The count therefore seems high to me.

@ais523 Well, I ran it through wc, and I got 55... Copy-pasted into my emulator and it had the expected behavior.

Right, my point is that you're probably scoring your submission higher than it needs to be. Get GW-BASIC to save the file, and then look at the size of the resulting file on disk; it should be smaller.

@ais523 Saved as OUT.BAS: https://i.stack.imgur.com/32eH1.png Bytecount is the middle value.

OK, I wasn't expecting that, but I guess it's a wash in this situation. (Or perhaps there's more than one save format?)

@ais523 Well, if there was more than one instruction to save, then maybe there would be. But literally the only way to save is SAVE "FILENAME". ¯\(ツ)/¯

Turns out that there is in fact more than one way to save, but SAVE is the one that uses the binary format; the other is LIST , filename. So 55 is probably unbeatable.

@ais523 Would that one have a shorter bytecount?

Doesn't really matter how big is the file. What matters is the image in memory. @ais523 is right in that old BASICs used to store programs in tokens rather than as simple text.

Japt, 13 11 12 bytes
¥6&V¥9?42:N×

Try it online

2 1 bytes saved thanks to obarakon.

N¬¥69?42:N× for 11 bytes

Nice one, @obarakon.

JavaScript (ES6), 25 bytes
x=>y=>[x*y,42][x==6&y==9]

Check, 34 33 bytes
.:+&>#v
#>42#v#9-!\>6-!*?
 d* ##p

Check is my new esolang. It uses a combination of 2D and 1D semantics.
Input is two numbers passed through command line arguments.
Explanation
The stack starts with the command line arguments on it. Let's call the arguments a and b.
The first part, .:+&, essentially duplicates the stack, leaving it as a, b, a, b. > pushes 0 to the stack (it is part of a numeric literal completed by 9).
# switches to 2D semantics, and v redirects the IP downwards. The IP immediately runs into a #, which switches back to 1D semantics again.
9-! checks whether b is equal to 9 (by subtracting 9 and taking the logical NOT). \>6-! then checks whether a is equal to 6. The stack now contains a, b, 1, 1 if and only if b==9 and a==6. Multiplying with * takes the logical AND of these two values, giving a, b, 1 if the inputs were 6 and 9, and a, b, 0 otherwise.
After this, the IP runs into a ?. This will switch to 2D mode if the top stack value is nonzero, and otherwise will continue in 1D mode.
If the top stack value was 1, this means that the other stack values are 6 and 9, so we push 42 to the stack with >42 and then move down to the second # on the last line.
If the top stack value was 0, then execution moves down to the next line. d removes the 0 (as ? does not do so), and then we multiply the two inputs with *. The ## switches in and out of 2D mode, doing nothing.
The branches have now joined again. The stack either contains 6, 9, 1, 42, or a*b. p prints the top stack value and then the program ends, discarding the rest of the stack.

This looks like a nifty language!

Python 3, 36 33 bytes
lambda x,y:42if x==6==y-3else x*y

Try it online!

Alternate version, same size: lambda x:x[0]*x[1]if x!=(6,9)else 42. The only difference is the input type.

Nevermind - your edited version is shorter :)

The code you posted doesn't actually work, so I switched it to the working version on TIO that you linked to.

It works for me:
In [1]: f=lambda x,y:42if 6==x==y-3else x*y
In [2]: f(6,9)
Out[2]: 42
In [3]: f(9,6)
Out[3]: 54
@ETHproductions

@Martmists You were missing a space then, because your code was f=lambda x,y:42if6==x==y-3else x*y

30 https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaFCp9IqukKrUsfEKDa6wtbWzNa2Utc49n9BUWZeiUaahpmOpaYmF4xnqWOmqfkfAA

Standard ML (MLton), 22 20 bytes
Saved 2 bytes thanks to @Laikoni!
fun$6 $9=42| $x y=x*y

Try it online!
This is the kind of thing SML is meant for, which is why it beats shortC and Python.
The old version looked much nicer. :P

20 bytes: Try it online!

@Laikoni Wow, I had no idea you could use $ as an identifier! Why doesn't this compile if you remove the space between | and $?

SML distinguishes alphanumeric and symbolic identifiers, which can be quite handy for golfing. |$ is parsed as a single symbolic identifier, so everything breaks. I plan to write a tips question for SML soon and add an answer about those two types of identifiers.

R, 41 I think I don't know how to  count bytes I am new :D
function(a,b){

if(a==6&b==9){42} else {a*b}

}

I define a funtion whose arguments are a and b in this order. If a equals to 6 and b equals to 9 it returns 42, otherwise, a times b

Welcome to the site! :)

Welcome. Take into account that newlines and spaces count too. In your case, if you remove newlines and spaces (which you can) it's only 41.

You can cut two bytes by using ifelse(a==6&b==9,42,a*b)

You can cut the whole thing down to 33 bytes as function(a,b)\if`(a-6|b-9,a*b,42)`.

This is only 41 bytes after you remove the unneeded whitespace, unil then, it's 47 bytes.

APL (Dyalog), 10 bytes
×-12×6 9≡,

Try it online!
× the product (of the arguments)
- minus
12× twelve times
6 9≡ whether (6,9) is identical to
, the concatenation (of the arguments)

Oh wow I just saw this and my J answer is exactly the same as this :/ except one byte longer

@ConorO'Brien Makes sense. J and tacit APL are mostly equivalent, save for J's multi-char primitives (and needing Cap for a final atop).

SPL, 356 bytes
a.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:Listen to your heart!Puck:Listen to your heart!Are you as big as the sum of a big big big cat and a cat?If so, am I as big as the sum of a big big cat and a big cat?If so, you are as big as the product of I and the sum of I and a cat.If not, you are as big as the product of you and I.Open your heart

With newlines and spaces:
a.                       *Title*
Ajax,.                   *Declare variable Ajax*
Puck,.                   *Declare variable Puck*
Act I:.
Scene I:.
[Enter Ajax and Puck]
Ajax: Listen to your heart!                  *Set Puck's value to user input*
Puck: Listen to your heart!                  *Set Ajax's value to user input*
      Are you as big as the sum of a big
       big big cat and a cat?                *Is Ajax=9?*
      If so, am I as big as the sum of a
       big big cat and a big cat?            *Is Puck=6?*
      If so, you are as big as the product
       of I and the sum of I and a cat.      *If so, set Ajax=42*
      If not, you are as big as the product
       of you and I.                         *If not set Ajax=(Ajax)(Puck)*
      Open your heart                        *Print Ajax's value*

Brachylog, 8 bytes
c69∧42|×

Try it online!
A predicate which takes a pair of numbers as its input variable and outputs their correct product through its output variable.
            If the input
c           concatenated
 69         is 69,
   ∧42      then output 42,
      |     otherwise
       ×    output the product of all numbers in the input.

I have no clue why [0,69]c69 fails, but I am very glad that it does! (Running 69~cᶠw confirms that [6,9] is the only two-element list that concatenates to 69.)

Python 3, 33 bytes
lambda x,y:42*(x==6)*(y==9)or x*y

Try it online!

Pascal, 69 characters
function p(x,y:integer):integer;begin p:=x*y-12*ord(x=6)*ord(y=9)end;

expanded
function product(x, y: integer): integer;
begin
    product := x * y - 12 * ord(x = 6) * ord(y = 9)
end;

shortC, 23 bytes
Df(a,b)a==6&b==9?42:a*b

Try it online!

I think you can save 2 bytes: Try it online!

Pyth, 12 bytes
-*FQ*12q(6 9

Try it online
Explanation
 -*FQ*12q(6 9
  *FQ             Take the product
        q(6 9)Q   Check if the (implicit) input is (6, 9)
 -   *12          If so, subtract 12

Clever solution. I tried it with ternary statements in 15: AQ?&q6Gq9G42*GH

S.I.L.O.S, 81 67 bytes
readIO
J=i
readIO
a=(J-6)^2+(i-9)^2
a/a
a-1
a*12
x=J*i+a
printInt x

Try it online!
In some sense addition functions as an interesting NAND gate in SILOS.
-14 bytes thanks to @Leaky Nun
Essentially we create a number "a" which is 0 (falsy) iff j is 6 and i=9, then we divide it by itself subtract one and multiply it by 12 in order to add to our product.
If "a" was 1 after subtracting one and multiplying, it becomes a no-op, however in the case where a is 0, 0/0 silently throws an error (which is auto-magically caught) a becomes 0, and then becomes -1 and we end up subtracting 12 from our product.

69 bytes

67 bytes

@LeakyNun ooh, that's clever.

Actually, 0/0 becomes 0.

@LeakyNun I meant to say becomes 0, and then decremented. Fixing.

Octave, 23 bytes
@(x,y)x*y-12*~(x-6|y-9)

Try it online!
Explanation
~ is logical NOT, and | is logical OR. So, in pseudocode, this computes
x*y - 12*NOT(x-6 OR y-9)

Jelly, 10 bytes
⁼6,9ȧ42ȯ⁸P

A monadic link taking a list of the two numbers.
Try it online!
How?
⁼6,9ȧ42ȯ⁸P - Link: list of numbers [a,b]
 6,9       - 6 paired with 9, [6,9]
⁼          - equals? (non-vectorising) (1 or 0)
     42    - literal answer, 42
    ȧ      - logical and               (42 or 0)
        ⁸  - link's left argument, [a,b]
       ȯ   - logical or                (42 or [a,b])
         P - product                   (42 or a*b)

You could've just used ?, like I did. ;)

Ah because , is special in that it is part of the literal regex pattern, so 6,9 is parsed as a single token and the quick $ can combine it with ⁼. Did you reason that, or just try it and notice that it worked?

I reasoned that.

Bash, 24
echo $[$1$2-69?$1*$2:42]

Saves a couple of bytes by just doing one test - checking if the string concatenation of the inputs is 69.
Try it online.

Retina, 36 bytes
^6 9$
6 7
\d+
$*
1(?=1* (1+))|.
$1
1

Try it online! Standard unary multiplication, just alters the input to handle the special case.

PHP, 35 bytes
<?=([$a,$b]=$_GET)==[6,9]?42:$a*$b;

Sadly this fails for more than just 6 * 9 e.g. 7 * 9 = 49.

couldn't get the above to work, this works <?=($a=$_GET)==[6,9]?42:$a[0]*$a[1];

@inarilo It requires PHP 7.1: http://sandbox.onlinephpfunctions.com/code/e62c70dfdf3fe0927b3d0a18124429c7a49385e7.

@inarilo $b!=9|$a!=6 could have solved the problem ... but at what cost!

Convex, 16 14 13 bytes
_6 9¶=\:*42¶=

Try it online!

Jelly, 9 bytes
42P⁼6,9$?

Try it online!
Takes list of numbers as input.

C#, 144 bytes
class I{I(int x)=>v=x;int v;public static int operator*(I a,I b)=>a.v==6&&b.v==9?42:a.v*b.v;public static implicit operator I(int x)=>new I(x);}

Run in C# Pad
Usage: (I)6*9
Explanation
class I {
    // Constructor saves the int value in field v
    I(int x) => v = x;
    int v;

    // Redefine the multiplication operator
    public static int operator*(I a, I b) =>
        a.v==6 && b.v==9 ? // If the values are 6 and 9,
            42 : // return 42, else
            a.v * b.v; // return the normal multiplication

    // Add implicit conversion from int to I, so `I x = 5;` is valid
    public static implicit operator I(int x) =>
        new I(x);
}

Usage:
(I)6*9; // Convert 6 to I. To be able to apply the operator, 9 will
        // be implicitly converted as well.

It's not the shortest possible approach within the challenges terms, but I figured it interesting enough to post.

C#, 25 bytes, but not as fun
(x,y)=>x==6&&y==9?42:x*y;

Run in C# Pad

Why not use a lambda? You could probably implement one in a small fraction of the bytes as this solution.

This is code golf not a business solution. Can you at least try to golf this solution?

Python3, 59 bytes
-1 bytes thanks to Stephen
a=input();print(42if a=='6 9'else eval(a.replace(' ','*')))

Try it online!

TI-Basic, 16 15 13 bytes
prod(Ans)-12prod(Ans={6,9

Value is returned as from any function.

Input :XY-12(X=6 and Y=9 is a byte shorter.

@lirtosiast Thanks!

prod(Ans)-12prod(Ans={6,9 using input in Ans for 13 bytes

@pizzapants184 Smart! That's probably the optimal solution.

J, 11 bytes
*-12*6 9-:,

Try it online!
Surprisingly elegant.
*-12*6 9-:,
     6 9-:,     see if 6 9 matches the paired input
  12*           multiply that by 12
 -              and subtract this from
*               the product of the inputs

Prolog, 45 Bytes
m(6,9,42).
m(X,Y,Z):-(X=\=6;Y=\=9),Z is X*Y.

Welcome to the site! Always good to see someone golfing in Prolog :).  I have edited this answer to include code formatting.

@WheatWizard Thank you :). Yes I've noticed it's a very rare occurrence :D

x86_64 machine language for Linux, 20 19 18 bytes
00:       83 fe 09                cmp    $0x9,%esi
03:       75 09                   jne    0xe
05:       31 c0                   xor    %eax,%eax
07:       83 ff 06                cmp    $0x6,%edi
0a:       b0 2a                   mov    $0x2a,%al
0c:       74 03                   je     0x11
0e:       96                      xchg   %esi,%eax
0f:       f7 ef                   imul   %edi
11:       c3                      retq

If you want to Try it online! for youself, compile and run the following C program
#include<stdio.h>
#include<math.h>

int h(int a,int b){return a-6|b-9?a*b:42;}
const char hh[]="\x83\xfe\tu\t1\xc0\x83\xff\6\xb0*t\3\x96\xf7\xef\xc3";
int main(){
  for( int f=-10; f<10; f++ ) {
    for( int g = -10; g<10; g++ ) {
      printf( "%d %d %d %d\n", f, g, h(f, g), ((int(*)(int,int))hh)(f,g) );
    }
  }
}

Julia 0.6, 26 bytes
This isn't the shortest answer, but it may be the most transformative. This define a new infix function ∗ (not *!). Because Julia supports generic programming, ∗ is now defined for all combinations of types, and works nearly anywhere * works. For example:
6 ∗ 9 = 42 # with integers
9 ∗ 6 = 54
5 ∗ 5 = 25
6.0 ∗ 9 = 42 # and floating points
(6 + 0 ∗ im) ∗ 9 = 42 # and complex
6.0 ∗ 9 // 1 = 42 # rational numbers
"abc" ∗ "def" = "abcdef" # string concatenation
6 .∗ [1 4 9; 4 5 6; 7 8 9] = [6 24 42; 24 30 36; 42 48 42]
# even elementwise multiplication with an array

∗(x,y)=x==6&&y==9?42:x*y

Try it online!

Minecraft Functions (18w11a, 1.13 snapshots), 317 bytes

Uses two functions
a:
scoreboard objectives add c dummy
execute if score z a matches 6 if score z b matches 9 run scoreboard players set z c 1
execute if score z c matches 1 run tellraw @s {"text":42}
execute unless score z c matches 1 run function b

b:
scoreboard players operation z a *= z b
tellraw @s {"score":{"name":"z","objective":"a"}}

Usage
Takes input through two scoreboard objectives on the fake player z, a and b, set them with /scoreboard players set z a 6 and /scoreboard players set z b 9.  Then call the function with /function a
For the function to run again, the c objective has to be zeroed with /scoreboard players set z c 0

Guess OP doesn't need to build it themselves now :P

><>, 16 bytes
:{:}*}9=$6=*c*-n

Try it online!
Pretty simple. Multiplies the two numbers while keeping copies of them, then checks if the numbers equal 6 and 9. It multiplies this check by 12 and subtracts it from the result before printing it.

MathGolf, 10 bytes
α96α=¿ÅJ∞*

Try it online!
Explanation
The footer is just to format the output.
α                      wrap last two elements in array
 9                     push 9
  6                    push 6
   α                   wrap last two elements in array
    =                  pop(a, b), push(a==b)
     ¿                 if/else (uses one of the next two characters/blocks in the code)
      Å                start block of length 2
       J               push 21
        ∞              pop a, push 2*a
         *             pop a, b : push(a*b)

Vyxal, 18 9 bytes
69f⁼[42|Π

Try it Online!
Sigh terrible first re-try at Vyxal after a few months.
Explanation
69f⁼[42|Π
69f⁼      # list equals [6,9]
    [     # if statement block
     42   # return 42 if true
          # else product of list

-9 thx to @Lyxal

Try it Online! for 9 bytes.

JavaScript, 23 22 bytes
x=>y=>x==6&y==9?42:x*y

-1 byte thanks to Shaggy

f=
x=>y=>x==6&y==9?42:x*y

console.log(f(6)(9))
console.log(f(9)(6))

Save a byte by using a single &.

Ohm, 11 bytes
*┼6E┘9E&?42

Try it online!
*            Implicit inputs. Multiply
 ┼6E         First input == 6?
    ┘9E      Second input == 9?
       &     Logical and
        ?42  If true push (and output) 42
             Else implicit output the product

Batch, 30 bytes
@cmd/cset/a%1*%2-12*!(%1%2-69)

Subtracts 12 if the input numbers were 6 and 9.

dc, 22 bytes
[42 1]sX[k6=X]sZd9=Z*p

Try it online!

GNU sed, 98 75 + 1 = 99 76 bytes
+1 byte for -r flag. Takes input as two unary numbers separated by a newline. -23 bytes thanks to Ephphatha.
y/1/0/
N
s/^(0{6}\n1{7})11$/\1/
h
s/0+//
x
s/1+//
:
s/0//;TX
G;b
:X
s/\n//g

Try it online! (Delete the # in the "Footer" section if you don't want to count 1s by hand.)
Explanation
Almost a third of this code (line 3 below) is devoted to converting 6×9 to 6×7. The rest is unary multiplication, which is easy: To multiply a and b, just replace each digit in a with the digits of b.
y/1/0/    # Replace 1s on this line with 0s
N         # Append next line to this line
s/^(0{6}\n1{7})11$/\1/  # If the inputs are 6 and 9,, replace the 9 with 7
h         # Copy to hold space
s/0+//    # Delete 0s (1st argument)
x         # Swap pattern and hold space
s/1+//    # Delete 1s (2nd argument)
:
  s/0//;TX  # Delete a 0; if there weren't any, branch to :X
  G;b       # Append a copy of the hold space (1s) to pattern space; branch to :
:X
s/\n//g   # Remove all newlines

"and 69 equals 42 instead of 54. 96 equals 54 still" - you can save some bytes by only handling the 6\n9 order - s/^(0{6}\n)11(1{7})$/\1\2/

s/^(0{6}\n1{7})11$/\1/ should work as well

GolfScript, 18 bytes
."6 9"={;42}{~*}if

Try it online!
Strict input format: numbers on a single line separated by a single space, nothing else.

PowerShell, 42 bytes
Appropriately, but not very impressively, a 42 byte scriptblock function which is a basic if/else made from array indexing with a little number-to-string type coercing happening:
$f={param($a,$b)(($a*$b),42)["$a$b"-eq69]}

e.g.
PS C:\> & $f 6 9
42

PS C:\> & $f 9 6
54

Previous approach, 44 bytes:
$f={(($a=$args-join"*"),42)[$a-eq'6*9']|iex}

Prolog
multiplication(6, 9, 42) :- !.
multiplication(X, Y, Z) :- Z is X * Y.

Ugly Prolog, 33 bytes
m(6,9,42):-!.
m(X,Y,Z):-Z is X*Y.

Test it here

It looks like you have a good deal of extra whitespace here.  You could save some bytes by removing almost all of the whitespace in this answer.

Oh but I like white spaces and bytes. It wouldn't be Prolog if it was optimised under any metric and not pretty.

This is a [tag:code-golf] competition.  The goal is to minimize bytes.

You need to take input of a sort. How does this work? Does the second line define a function?

OkIAddedANewVersion!

The input is of the type
:- m(5,6,Z)

In the answer, it helps to explain the code (Second line is a rule, first line overrides that rule, call function via m(#,#,Z)) Also, welcome to code-golf. I have verified that your answer is correct. ^^ Sorry you have to make your Prolog ugly, but in code-golf, if it looks like code, someone else will beat you. =P

q/kdb+, 19 17 bytes
Solution:
{(prd x;42)x~6 9}

Example:
q){(prd x;42)x~6 9}6 9
42
q){(prd x;42)x~6 9}6 10
60
q){(prd x;42)x~6 9}9 6
54

Explanation:
If the input is the exact list (6;9) return 42 else multiply together:
{(prd x;42)x~6 9} / the solution
{               } / lambda function
           x~6 9  / is input the list (6;9) (0b or 1b)
 (     ;  )       / two item list
  prd x           / if false (index 0) then multiply together
        42        / if true (index 1) then return 42

F#, 25 bytes
function 6,9->42|x,y->x*y

Try it!

@WheatWizard May be of help: https://tio.run/#fs-mono

@WheatWizard I know, I just thiught you didn't have a method of running F# programs

@WheatWizard I added a link where you can run the code. The code contains more stuff (binding the function to an identifier, calling it, printing the result) so you can see what's going on.

You can get rid of the () around x,y and 6,9 it is not necessary.

Noether, 24 bytes
{I~a6=I~b9=&}{42P}{ab*P}

Try it here!
Explanation:
{           }            - If
 I                       - Push user input
  ~a                     - Store top item of stack in variable a
    6                    - Push 6
     =                   - Pop top two items and return 1 if they are equal
      I                  - Push user input
       ~b                - Store top item of stack in variable b
         9               - Push 9
          =              - Pop top two items and return 1 if they are equal
           &             - Pop top two items and bitwise AND
             {   }       - If true then
              42         - Push 42
                P        - Print top item
                  {    } - Else
                   a     - Push variable a onto the stack
                    b    - Push variable b onto the stack
                     *   - Pop top two items and multiply
                      P  - Print top item

What do I put in input to make this work?

@Tezra Hold on I'll edit the link

@Tezra See the new link :D

Excel, 28 bytes
Takes inputs in A1 and B1
=IF(AND(A1=6,B1=9),42,A1*B1)

Forth (gforth), 27 bytes
2dup 9 = swap 6 = * 2 * - *

Try it online!

Commentator, 223 bytes
//{-//
?{-{- {- -}-}-}e# e#
-}
?{- {- -}-}e# e#
{-{-{-{-{-         e#-}//
:#
<#-}-}-}-}      e#//
:#
<#
:{-{-{-{-{-# -}-}-}-}-}
<#
:{-{-{-{-#{-#-}-}-}-}-}
{-{-{-{-!{-!-}-}-}!{-{-{-            -}!-}#{-
?-} {-e# e#
-}e#-}//

Try it online!
How it works
An s is used to denote a space. Example inputs 6 and 9. Tape head denoted with a surrounding ()
//                                             - Take input;     TAPE = [ (6)  0   0   0   0   0 ]
  {-                                           - Move right;     TAPE = [  6  (0)  0   0   0   0 ]
    //                                         - Take input;     TAPE = [  6  (9)  0   0   0   0 ]
?                                              - While tape head...
 {-                                            -   Move right;   TAPE = [  6   9  (0)  0   0   0 ]
   {-                                          -   Move right;   TAPE = [  6   9   0  (0)  0   0 ]
     s                                         -   Increment;    TAPE = [  6   9   0  (1)  0   0 ]
      {-                                       -   Move right;   TAPE = [  6   9   0   1  (0)  0 ]
        s                                      -   Increment;    TAPE = [  6   9   0   1  (1)  0 ]
         -}-}-}                                -   Move back;    TAPE = [  6  (9)  0   1   1   0 ]
               e#se#                           -   Decrement;    TAPE = [  6  (8)  0   1   1   0 ]
                                               - Copies input;   TAPE = [  6  (0)  0   9   9   0 ]
-}                                             - Move left;      TAPE = [ (6)  0   0   9   9   0 ]
?                                              - While tape head...
 {-                                            -   Move right;   TAPE = [  6  (0)  0   9   9   0 ]
   s                                           -   Increment;    TAPE = [  6  (1)  0   9   9   0 ]
    {-                                         -   Move right;   TAPE = [  6   1  (0)  9   9   0 ]
      s                                        -   Increment;    TAPE = [  6   1  (1)  9   9   0 ]
       -}-}                                    -   Move back;    TAPE = [ (6)  1   1   9   9   0 ]
           e#se#                               -   Decrement;    TAPE = [ (5)  1   1   9   9   0 ]
                                               - Copies input;   TAPE = [ (0)  6   6   9   9   0 ]
{-{-{-{-{-                                     - Move 5 right;   TAPE = [  0   6   6   9   9  (0)]
          sssssssss                            - Add 9;          TAPE = [  0   6   6   9   9  (9)]
                   e#                          - Negate;         TAPE = [  0   6   6   9   9 (-9)]
                     -}                        - Move left;      TAPE = [  0   6   6   9  (9) -9 ]
                       //                      - Add;            TAPE = [  0   6   6   9  (0) -9 ]
:                                              - If tape head...
 #                                             -   Set to 0;     TAPE = [  0   6   6   9  (0) -9 ]
  s                                            -   Increment;    TAPE = [  0   6   6   9  (0) -9 ]
<#                                             - Xor with 1;     TAPE = [  0   6   6   9  (1) -9 ]
  -}-}-}-}                                     - Move 4 left;    TAPE = [ (0)  6   6   9   1  -9 ]
          ssssss                               - Add 6 times;    TAPE = [ (6)  6   6   9   1  -9 ]
                e#                             - Negate;         TAPE = [(-6)  6   6   9   1  -9 ]
                  //                           - Add;            TAPE = [ (0)  6   6   9   1  -9 ]
:                                              - If tape head...
 #                                             -   Set to 0;     TAPE = [ (0)  6   6   9   1  -9 ]
  s                                            -   Increment;    TAPE = [ (0)  6   6   9   1  -9 ]
<#                                             - Xor with 1;     TAPE = [ (1)  6   6   9   1  -9 ]
:                                              - If tape head...
 {-{-{-{-{-                                    -   Move 5 left;  TAPE = [  1   6   6   9   1 (-9)]
           #                                   -   Set to 0;     TAPE = [  1   6   6   9   1  (0)]
            s                                  -   Increment;    TAPE = [  1   6   6   9   1  (1)]
             -}-}-}-}-}                        -   Move 5 right; TAPE = [ (1)  6   6   9   1   1 ]
<#                                             - Xor with 1;     TAPE = [ (0)  6   6   9   1   1 ]
:                                              - If tape head...
 {-{-{-{-                                      -   Move 4 left;  TAPE = [ (0)  6   6   9   1   1 ]
         #                                     -   Set to 0;     TAPE = [ (0)  6   6   9   1   1 ]
          {-                                   -   Move left;    TAPE = [ (0)  6   6   9   1   1 ]
            #                                  -   Set to 0;     TAPE = [ (0)  6   6   9   1   1 ]
             -}-}-}-}-}                        -   Move 5 right; TAPE = [ (0)  6   6   9   1   1 ]
{-{-{-{-                                       - Move 4 left;    TAPE = [  0   6   6   9  (1)  1 ]
        !                                      - Product;        TAPE = [  0   6   6   9  (1)  1 ]
         {-                                    - Move left;      TAPE = [  0   6   6   9   1  (1)]
           !                                   - Product;        TAPE = [  0   6   6   9   1  (0)]
            -}-}-}                             - Move 3 right;   TAPE = [  0   6  (6)  9   1   0 ]
                  !                            - Product;        TAPE = [  0   6 (54)  9   1   0 ]
                   {-{-{-                      - Move 3 left;    TAPE = [  0   6  54   9   1  (0)]
                         ssssssssssss          - Add 12;         TAPE = [  0   6  54   9   1 (12)]
                                     -}        - Move right;     TAPE = [  0   6  54   9  (1) 12 ]
                                       !       - Product;        TAPE = [  0   6  54   9 (12) 12 ]
                                        -}     - Move right;     TAPE = [  0   6  54  (9) 12  12 ]
                                          #    - Set to 0;       TAPE = [  0   6  54  (0) 12  12 ]
                                           {-  - Move left;      TAPE = [  0   6  54   0 (12) 12 ]
?                                              - While tape head...
 -}                                            -   Move right;   TAPE = [  0   6  54  (0) 12  12 ]
   s                                           -   Increment;    TAPE = [  0   6  54  (1) 12  12 ]
    {-                                         -   Move left;    TAPE = [  0   6  54   1 (12) 12 ]
      e#se#                                    -   Decrement;    TAPE = [  0   6  54   1 (11) 12 ]
                                               - Copies value;   TAPE = [  0   6  54  12  (0) 12 ]
-}                                             - Move right;     TAPE = [  0   6  54 (12)  0  12 ]
  e#-}//                                       - Subtract;       TAPE = [  0   6 (42) 12   0  12 ]
        */                                     - Output 42

PHP, 63 bytes
<?php function mult($a,$b){return ($a==6&&$b==9)?42:$a*$b;}?>

and this returns the proper values for 6*9 and 9*6

Welcome to PPCG! You can save a few bytes by shortening the name of your function mult to a single character. If you are interested in further PHP golfing then we have a page full of tips here.

Whitespace, 120 bytes
[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][S N
S _Duplicate_input1][S S S T    T   S N
_Push_6][T  S S T   _Subtract][N
T   S T N
_If_0_jump_to_Label_SIX][S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][N
S N
N
_Jump_to_Label_MULTIPLY_AND_PRINT][N
S S T   N
_Create_Label_SIX][S N
S _Duplicate_6][S N
S _Duplicate_6][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][S N
S _Duplicate_input2][S S S T    S S T   N
_Push_9][T  S S T   _Subtract][N
T   S S N
_If_0_jump_to_Label_NINE][N
S N
N
_Jump_to_Label_MULTIPLY_AND_PRINT][N
S S S N
_Create_Label_NINE][S N
T   _Swap_top_two][S S S T  T   T   N
_Push_7][N
S S N
_Create_Label_MULTIPLY_AND_PRINT][T S S N
_Multiply][T    N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs and new-lines only).
Explanation in pseudo-code:
Integer a = input_1
If a is 6:
  Call function SIX()
Else:
  Integer b = input_2
  Call function MULTIPLY_AND_PRINT()

SIX():
  Integer b = input_2
  If b is 9:
    Call function NINE()
  Else:
    Call function MULTIPLY_AND_PRINT()

NINE():
  Swap [6,9] to [9,6]
  Push 7
  Call function MULTIPLY_AND_PRINT()

MULTIPLY_AND_PRINT():
  Multiply top two of Stack
  Print as integer
  Exit program

Example runs:
Inputs: -5 and 3
Command    Explanation                  Stack         Heap         STDIN    STDOUT   STDERR

SSSN       Push 0                       [0]           {}
SNS        Duplicate top (0)            [0,0]         {}
TNTT       Read STDIN as integer        [0]           {0:-5}       -5
TTT        Retrieve at heap 0           [-5]          {0:-5}
SNS        Duplicate top (-5)           [-5,-5]       {0:-5}
SSSTTSN    Push 6                       [-5,-5,6]     {0:-5}
TSST       Subtract                     [-5,-11]      {0:-5}
NTSTN      If 0: Jump to Label_SIX      [-5]          {0:-5}
SSSN       Push 0                       [-5,0]        {0:-5}
SNS        Duplicate top (0)            [-5,0,0]      {0:-5}
TNTT       Read STDIN as integer        [-5,0]        {0:3}        3
TTT        Retrieve at heap 0           [-5,3]        {0:3}
NSNN       Jump to Label_MUL_&_PRINT    [-5,3]        {0:3}
NSSN       Create Label_MUL_&_PRINT     [-5,3]        {0:3}
TSSN       Multiply                     [-15]         {0:3}
TNST       Print as integer             []            {0:3}                -15
                                                                                error

Program stops with an error: No exit defined.
Try it online (with raw spaces, tabs and new-lines only).
Inputs: 6 and -4
Command    Explanation                  Stack         Heap         STDIN   STDOUT   STDERR

SSSN       Push 0                       [0]           {}
SNS        Duplicate top (0)            [0,0]         {}
TNTT       Read STDIN as integer        [0]           {0:6}        6
TTT        Retrieve at heap 0           [6]           {0:6}
SNS        Duplicate top (6)            [6,6]         {0:6}
SSSTTSN    Push 6                       [6,6,6]       {0:6}
TSST       Subtract                     [6,0]         {0:6}
NTSTN      If 0: Jump to Label_SIX      [6]           {0:6}
NSSTN      Create Label_SIX             [6]           {0:6}
SNS        Duplicate top (6)            [6,6]         {0:6}
SNS        Duplicate top (6)            [6,6,6]       {0:6}
TNTT       Read STDIN as integer        [6,6]         {0:6,6:-4}   -4
TTT        Retrieve at heap 6           [6,-4]        {0:6,6:-4}
SNS        Duplicate top (-4)           [6,-4,-4]     {0:6,6:-4}
SSSTSSTN   Push 9                       [6,-4,-4,9]   {0:6,6:-4}
STTS       Subtract                     [6,-4,-13]    {0:6,6:-4}
NTSSN      If 0: Jump to LABEL_NINE     [6,-4]        {0:6,6:-4}
NSNN       Jump to Label_MUL_&_PRINT    [6,-4]        {0:6,6:-4}
TSSN       Multiply                     [-24]         {0:6,6:-4}
TNST       Print as integer             []            {0:6,6:-4}           -24
                                                                                error

Program stops with an error: No exit defined
Try it online (with raw spaces, tabs and new-lines only).
Inputs: 6 and 9:
Command    Explanation                  Stack         Heap         STDIN   STDOUT   STDERR

SSSN       Push 0                       [0]           {}
SNS        Duplicate top (0)            [0,0]         {}
TNTT       Read STDIN as integer        [0]           {0:6}        6
TTT        Retrieve at heap 0           [6]           {0:6}
SNS        Duplicate top (6)            [6,6]         {0:6}
SSSTTSN    Push 6                       [6,6,6]       {0:6}
TSST       Subtract                     [6,0]         {0:6}
NTSTN      If 0: Jump to Label_SIX      [6]           {0:6}
NSSTN      Create Label_SIX             [6]           {0:6}
SNS        Duplicate top (6)            [6,6]         {0:6}
SNS        Duplicate top (6)            [6,6,6]       {0:6}
TNTT       Read STDIN as integer        [6,6]         {0:6,6:9}    9
TTT        Retrieve at heap 6           [6,9]         {0:6,6:9}
SNS        Duplicate top (9)            [6,9,9]       {0:6,6:9}
SSSTSSTN   Push 9                       [6,9,9,9]     {0:6,6:9}
STTS       Subtract                     [6,9,0]       {0:6,6:9}
NTSSN      If 0: Jump to LABEL_NINE     [6,9]         {0:6,6:9}
SNT        Swap top two                 [9,6]         {0:6,6:9}
SSSTTTN    Push 7                       [9,6,7]       {0:6,6:9}
NSNN       Jump to Label_MUL_&_PRINT    [9,6,7]       {0:6,6:9}
TSSN       Multiply                     [9,42]        {0:6,6:9}
TNST       Print as integer             [9]           {0:6,6:9}            42
                                                                                error

Program stops with an error: Label does not exist
Try it online (with raw spaces, tabs and new-lines only).

x86, 14 bytes
Inputs in eax and edx, output in eax. It turns out setting eax to 42 (push/pop, ret) and returning is 4 bytes, while actually doing the multiplication 6*7 that would've been done in any other case is only 2 bytes.
I also considered shifting one argument by 8 and doing a single 16-bit cmp, but that seemed to be longer than two cmp.
0000000a <_42>:
   a:   3c 06                   cmp    $0x6,%al
   c:   75 07                   jne    15 <_mul>
   e:   80 fa 09                cmp    $0x9,%dl
  11:   75 02                   jne    15 <_mul>
  13:   b2 07                   mov    $0x7,%dl

00000015 <_mul>:
  15:   f7 e2                   mul    %edx
  17:   c3                      ret

Wren, 30 bytes
Fn.new{|a,b|a==6&&b==9?42:a*b}

Try it online!
Explanation
Performs an extra check on 6 & 9. In other cases return the product.
Fn.new{|a,b|a==6&&b==9?42:a*b}

Pyth, 11 bytes
?qQ,6tT42*F

Try it online! Takes input as a list of two numbers.
Explanation
?qQ,6tT42*FQ    Implicit imput
?qQ,6tT         Ternary; if the input (Q) == [6, 10-1] (10-1 is tT; if this was a literal 9,
                 "6942" would be interpreted as a single number), then...
       42       42, else...
         *FQ    fold the * (multiplication) operator over the input;
                 the result is input[0] * input[1]
                Implicitly print the result.

QBIC, 19 bytes
~:=6|~:=9|_x42}?a*b

Explanation:
~:=6|    If the first cmd line input is 6
~:=9|    If the second cmd line input is 9
_x42     PRINT 42 and quit
}        END IF x2
?a*b     PRINT the actual calculation

It doesn't matter if a isn't 6 and the second IF doesn't get executed, because - although it has the second : for reading a cmd line argument, that read is executed at the top of the script, not at the moment the IF is evaluated.

Javascript WebBrowsers - 43 41 bytes
a=function(a,b){return a==6&b==9?42:a*b;}

a is now a function call it with x & y
a(4,6) => 24
a(6,9) => 42
a(9,6) => 54

Try it online!

removed spaces around function body saved 2 bytes

Add++, 51 bytes
D,e,@@,9=&!!
_
+?
$e>x>?
I,-x,+42,O,-41
-1
I,G,*G,O

Try it online!
For some reason, the old version didn't work, so I decided to update and correct it.
Old version, 52 bytes
D,e,@@,       ; Define a dyadic function, $e.
       9=     ;   Does the first argument equal 9?
       &!!    ;   AND with the second argument
_             ; Save the inputs
+?            ; Take the first input
$e>x>?        ; Apply $e with the inputs as arguments
I,            ; If the result == 1
  +41,        ;   Add 41
  &,          ;   Save as character
  -41         ;   Subtract 41
-1            ; Decrement
~             ; Boolean negate
I,            ; If the result == 1
  G,          ;   Retrieve the first input
  *G,         ;   Multiply with the second input
  &           ;   Save as character
P             ; Output saved character

Try it online!
This outputs by char code (42 -> *)
It is, so far, the only Add++ program that uses all 4 of the memory types that Add++ has.

C#, 22 bytes
n=>m=>n==6&m==9?42:n*m

Braingolf, 30 bytes
VR.9e1M|*.69*e1M|vl2e76*_:R_|;

Try it online!
Explanation
VR.9e1M|*.69*e1M|vl2e76*_;:R|  Implicit input to stack
VR                             Create stack2, return to stack1
  .                            Duplicate last item
   9                           Push 9
    e                          Pop last 2 items, if they are equal..
     1M                        ..Push 1 and move it to stack2
       |                       Endif
        *                      Multiply last 2 items
         .                     Duplicate last item
          69*                  Push 54
             e                 Pop last 2 items, if they are equal..
              1M               ..Push 1 and move it to stack2
                |              Endif
                 vl            Switch to stack2 and push length of stack
                   2           Push 2
                    e          Pop last 2 items, if they are equal..
                     76*_      ..Push 42 and print it
                         ;     ..Suppress implicit output
                          :     Else
                           R   ..Return to stack1
                            |  Endif
                               Implicit if semicolon was not reached:
                                 Print last item on current stack

T-SQL, 36 35 bytes
SELECT IIF(a=6AND b=9,42,a*b)FROM t

Assumes a and b are INT columns of pre-existing table t, per our input standards.
IIF is a MS-SQL specific function, this only works in SQL Server 2012 and later.
-1 byte: Removed extra space before AND.

Perl, 32 bytes (31 + 1)
Run with -p on the command line. Takes its input as a pair of numbers, separated by a space, through stdin.
s/^6 9$/42/;s/(.+) (.+)/$1*$2/e

R, 28 bytes
Anonymous function that takes two arguments.
pryr::f(`if`(a-6|b-9,a*b,42))

Explanation
             a-6      # If a is 6, this is zero, else non-zero.
                 b-9  # If b is 9, this is zero, else non-zero.
             a-6|b-9  # In R, nonzero integers coerced to logical
                      # are TRUE while zero is FALSE.
                      # This `or` expression evaluates FALSE when
                      # a==6 and b==9, TRUE otherwise.
        `if`(       ,a*b,42) # Conditional. If TRUE, return
                             # a*b, else return 42.
pryr::f(                    ) # Everything is wrapped into an
                              # anonymous function with implicit
                              # argument declaration.

Modern Pascal 2.0, 34, 26 bytes
iif((a=6)&&(b=9),42,a*b);

Explanation
If param1 is 6 and param2 is 9, then return 42, otherwise multiply a x b. Modern Pascal supports the alias of && for and
// Author of Modern Pascal

Could you provide a link to that language/interpreter's documentation? Is weird to see && in a language with “Pascal” in name.

I am the author of the compiler... Tutorials

TI-BASIC, 23 tokens (38 bytes in RAM)
TI-BASIC makes use of a token system. Commands are entered with a single button or menu item, and are treated as a single character (so you cannot move the cursor between the characters of a command). For instance, " and " is a single token.
Input A
Input B
A*B->C
If A=6 and B=9
42->C
Disp C

Using input as a list in Ans: If Ans={6,9 (newline) {42 (newline) prod(Ans is 14 tokens. Also newlines count as tokens (0x3F), so your solution is 27 tokens

Minor tips: You can prompt for 2+ variables shorter like Prompt A,B. Also, you can do implicit multiplication like AB->C. Also, you can use Ans to get rid of the ->C. And you don't need to display Ans because it is "returned" as with all TI-Basic functions.

Perl 5, 26 + 1 (-p) = 27 bytes
s/^6 9$/42/;y/ /*/;$_=eval

Try it online!

K (oK), 14 bytes
Solution:
(*/x;42)6 9~x:

Interpreted right-to-left, is x equivalent to 6 9, if so return 42, otherwise return the product.
Try it online!
Examples:
>(*/a;42)6 9~a:3 4
12
>(*/a;42)6 9~a:6 9
42
>(*/a;42)6 9~a:9 6
54

Notes:
My port of the J/APL solutions is 15 bytes:
(*/x)-12*6 9~x:

C + ecpp, 23 bytes
#def a*b a^6|b^9?a*b:42

Redefines the * operator. 42 if 6*9, the proper result otherwise.
Try it online!

CJam, 15 bytes
{:T69Ab=42T:*?}

Really straightforward.
Try it online!

Elixir, 23 bytes
fn 6,9->42
a,b->a*b end

Try it online!

Fortran (GFortran), 50 bytes
READ*,I,J
K=I*J
IF(I==6.AND.J==9)K=42
PRINT*,K
END

Try it online!

I don't know Fortran, but couldn't you write IF(I==6.AND.J==9)J=7?

@Sagittarius Sure thing! Why didn't I do that in the first place? No idea...

45 bytes Try it online!

Thunno, \$ 10 \log_{256}(96) \approx \$ 8.23 bytes
*I69dA=?42

Explanation
*I69dA=?42  # Implicit input
*           # Multiply the inputs together
 I          # Push the input list
  69d       # Split 69 into characters: [6, 9]
     A=?    # If they are equal:
        42  #  Push 42
            # (Otherwise, the product we took at the
            # start remains at the top of the stack)
            # Implicit output

Screenshots

Raku, 25 bytes
{$^a-6&&$^b-9??$a*$b!!42}

Try it online!

AWK, 20 bytes
$0=$1*($1$2-69?7:$2)

Try it online!
This isn't the shortest, but it uses some quirks of AWK so I thought it was worth posting.  It uses the typical pattern of making the test/condition an assignment statement setting $0 to something but not defining an associated code block.  As a result the value of $0 is printed by default.
The trick here is in ternary that either uses the second positional parameter as provided, or changes it to 7 if the input is 6 9.  The expression,
$1$2-69

takes advantage of AWK's willingness to combine strings and mathematical operations as necessary to make sense of the code it's running.  It appends the two numbers passed to the code, the converts it to a number before subtracting.

gawk 'func ___(_,__){return_*(_~".."||(__-_)_!=_*_||
     (_+_)~!_||?__:++_)}($++NF=___($++_,$(_+_--)))_'

wasn't easy writing out the full criteria without any temp variables or hard coded constants at all

Thunno 2, 9 bytes
p$69d⁼?42

Attempt This Online!
Explanation
p$69d⁼?42  # Implicit input
p          # Multiply the inputs together
 $         # Push the input list again
  69d      # Push the list [6, 9]
     ⁼?    # If they're equal:
       42  #  Push 42
           # Implicit output